Plotting and saving the picture with pcolor

6 views (last 30 days)
Hello!
I have 180 data variables, which I would like to plot with pcolor and look at for 5 seconds and then it would be saved as .png, but I can't even get the first part to work. Here is my code:
list=who;
pause on
for i=1:180
pcolor(list(i));shading flat;colorbar
pause 5
end
As I understand, the variable list has strings with apostrophes, so list(i) will be 'variablename'. If anyone could help with the code, it would be very appreciated.
  3 Comments
inga
inga on 10 Mar 2013
Each variable in the list is a 750x660 numerical data array, to which pcolor is the best option.
Image Analyst
Image Analyst on 10 Mar 2013
I'd need more proof than that. Why do you want to lose the last row and column? Why can't image() or imshow() work in your situation, like they do for everyone else's 750x660 numerical array?

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 10 Mar 2013
Edited: Image Analyst on 10 Mar 2013
Try this:
clc;
close all;
% Get rid of verything except the new variables which we will create.
clear all;
image1 = uint8(randi(255, [750, 660]));
image2 = uint8(randi(255, [750, 660]));
image3 = uint8(randi(255, [750, 660]));
% Get a cell array of the NAMES of the variables.
list=who;
% Loop over them, displaying each
for k = 1 : size(list, 1)
% Display it with image()
commandLine = sprintf('image(%s)', list{k});
eval(commandLine);
title(list{k}, 'FontSize', 30);
% Apply a colormap and show a colorbar.
colormap (jet(256));
colorbar
% Pause for 5 seconds to let user view it.
pause(5);
end
msgbox('Done with demo');
  2 Comments
inga
inga on 11 Mar 2013
Thank you so so much with this, I edited this a bit and got it working.
Image Analyst
Image Analyst on 11 Mar 2013
Edited: Image Analyst on 11 Mar 2013
OK, great. Note that when you build this into your code, get rid of the code before the list=who command so that you don't blow away any variables and windows that your code needs (such as a GUIDE handles structure or things like that). Mark this Answer as "Accepted" if this solution works for you.

Sign in to comment.

More Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 8 Mar 2013
Edited: Azzi Abdelmalek on 8 Mar 2013
Example
list={magic(4),magic(5)}
for i=1:numel(list)
pcolor(list{i}) ;
shading flat;
colorbar
pause(5)
end

Tags

Community Treasure Hunt

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

Start Hunting!