Loading Multiple Images From Simulink User-Defined Script
Hello
I have been developing a Simulink model that attempts to load a series of JPG images from a local folder. To the best of my knowledge, Simulink does not offer a built-in block with such capability and that is why I am using a user-defined function. To construct the image titles, I am using a for-loop as following:
for i = 1:5
for j = 1:5
title = [int2str(i),’_’,’int2str(j)’,’.jpg’];
image = imread(title);
end
end
When using the above code, I get the dimensionality error in Simulink that suggest the imread function can’t load an image with such naming construction:
Error message: Dimension 1 is fixed on the left-hand side but varies on the right ([369 x 440 x 3] ~= [:? x 😕 x :?]).
However, if I just write the title name in the script (e.g. title = [‘1_1.jpg’]) things work fine. My other problem is regarding converting this Simulink block into C codes. Even if I define the image title in the script (which works fine for Simulink), the coder will give the above error message.
I really appriciate any help and suggestion on these mattersHello
I have been developing a Simulink model that attempts to load a series of JPG images from a local folder. To the best of my knowledge, Simulink does not offer a built-in block with such capability and that is why I am using a user-defined function. To construct the image titles, I am using a for-loop as following:
for i = 1:5
for j = 1:5
title = [int2str(i),’_’,’int2str(j)’,’.jpg’];
image = imread(title);
end
end
When using the above code, I get the dimensionality error in Simulink that suggest the imread function can’t load an image with such naming construction:
Error message: Dimension 1 is fixed on the left-hand side but varies on the right ([369 x 440 x 3] ~= [:? x 😕 x :?]).
However, if I just write the title name in the script (e.g. title = [‘1_1.jpg’]) things work fine. My other problem is regarding converting this Simulink block into C codes. Even if I define the image title in the script (which works fine for Simulink), the coder will give the above error message.
I really appriciate any help and suggestion on these matters Hello
I have been developing a Simulink model that attempts to load a series of JPG images from a local folder. To the best of my knowledge, Simulink does not offer a built-in block with such capability and that is why I am using a user-defined function. To construct the image titles, I am using a for-loop as following:
for i = 1:5
for j = 1:5
title = [int2str(i),’_’,’int2str(j)’,’.jpg’];
image = imread(title);
end
end
When using the above code, I get the dimensionality error in Simulink that suggest the imread function can’t load an image with such naming construction:
Error message: Dimension 1 is fixed on the left-hand side but varies on the right ([369 x 440 x 3] ~= [:? x 😕 x :?]).
However, if I just write the title name in the script (e.g. title = [‘1_1.jpg’]) things work fine. My other problem is regarding converting this Simulink block into C codes. Even if I define the image title in the script (which works fine for Simulink), the coder will give the above error message.
I really appriciate any help and suggestion on these matters simulink, imread MATLAB Answers — New Questions
​