Plotting Images on a Subplot from a Loop

Hello,
I am using a loop to load and analyse images, I now want to be able to load a sample of the images and plot them on a subplot.
so far this is what I have tried, it just has an issue with the subplot, have sucesfully loaded all the images.
Any suggestions?
figure
x=0;
for K = 431:10:481
FileName=strcat('Embryo1_', sprintf('%03d',K),'.tif');
I = imread(FileName);%load image
x=x+1;
subplot(1,6,x)
imshow(I)
end

3 Comments

... it just has an issue with the subplot ...
Which is ... ?
"it just has an issue with the subplot"
And what might that be?
The crystal ball is in the shop (yet) again...
Attempt to execute SCRIPT subplot as a function:
C:\Users\Lizzy\Documents\Year 3\EG-353 Research Project\Embryo images\Embryo images project\subplot.m
Error in notmatlab (line 19)
subplot(1,6,x)
is what is shown as an error message, I meant more that up until the subplot section everything works.

Sign in to comment.

 Accepted Answer

Star Strider
Star Strider on 31 Mar 2019
Edited: Star Strider on 31 Mar 2019
Rename your ‘subplot.m’ function to something else, for example:
C:\Users\Lizzy\Documents\Year 3\EG-353 Research Project\Embryo images\Embryo images project\Lizzy_subplot.m
That should solve it.

5 Comments

I tried that, but it still shows that error message with subplot on the end of the address?
It shouldn’t.
What exactly did you try?
Changing the name of your .m file is an operating system command. You can do it from MATLAB with the movefile (link) function, however it’s easier using operating system utilities, such as ’File Explorer’ on Windows.
this is what my screen shows, in the original code I showed I had renamed it 'notmatlab' and the same thing, sorry if i'm just being dense.matlab1snip.JPG
So I completely deleted the subplot file, and it worked, thank you for the help!
As always, my pleasure!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!