error in subplot
1 view (last 30 days)
Show older comments
sir i have 15 images in a folder names,mri,i load this folder to perform 4 operations,low pass,high pass etc,
so there are 15 images in low and high pass amd so on,wen i subplot for each,15th low pass figure is repacles by first image oh gigh pass and so on,can u tell how to process please
pathname ='C:\mri\' ;
dirlist = dir( [pathname '*.tif'] );
pickind='tif';
for m = 1:length(dirlist)
i = imread([pathname, dirlist(m).name]);
A=i;
figure(1),subplot(4,4,m),imshow(A);
figure(2),subplot(4,4,m),imshow(B),title('low pass filter coefficients');
figure(3),subplot(4,4,m),imshow(C),title('high pass filter coefficients');
6 Comments
Jan
on 8 Oct 2011
@FIR: There is no reason for shouting. I just want to help, but I need an exact description of the error. Usually "error" means, that Matlab stops the execution with a descriptive message in the command window. In this case, it is helpful to post a copy of this message.
If you have another problem, it would be helpful if you describe it with more details. "The error is in the last image" and "that image must come in next figure" does not contain the necessary details. Do you simply want to run the loop until 14 and open a new figure afterwards? Then:
if m==14, figure(4) ...
BTW, what is "B" and "C"?
Your code would be easier to read, if you apply the standard code formatting used in this forum. Follow the "Markup help" link to learn more.
Accepted Answer
Walter Roberson
on 8 Oct 2011
It is not a good idea to rely upon implicit parenting of a graphical object when you have more than one figure or axes (and a GUI is a figure for this purpose.) This is especially true in the debugging phase: if you stop in the middle of constructing the graphics, then there is a substantial chance that the "current figure" or "current axes" will change in between program statements.
f = figure(1); h = subplot(4,4,m,'Parent',f); imshow(h, A);
f = figure(2); h = subplot(4,4,m,'Parent',f); imshow(h, B); title(h, 'low pass filter coefficients');
f = figure(3); h = subplot(4,4,m,'Parent',f); imshow(h, C); title(h, 'high pass filter coefficients');
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!