Plotting and saving the picture with pcolor

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 Kommentare

Image Analyst
Image Analyst am 8 Mär. 2013
Bearbeitet: Image Analyst am 8 Mär. 2013
If "list" is a variable containing strings with apostrophes in them (like perhaps a list of filenames or something), then why do you want to display that with pcolor(), which is intended for numerical data? Is list a cell array, or a character array, or a numerical array? What does it look like if you do
list
whos list
on the command line? Even is list is a numerical array with one number per index, then why are you using pcolor, where you lose the last column and last row, rather than image()?
inga
inga am 10 Mär. 2013
Each variable in the list is a 750x660 numerical data array, to which pcolor is the best option.
Image Analyst
Image Analyst am 10 Mär. 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?

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Image Analyst
Image Analyst am 10 Mär. 2013
Bearbeitet: Image Analyst am 10 Mär. 2013

0 Stimmen

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 Kommentare

inga
inga am 11 Mär. 2013
Thank you so so much with this, I edited this a bit and got it working.
Image Analyst
Image Analyst am 11 Mär. 2013
Bearbeitet: Image Analyst am 11 Mär. 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 8 Mär. 2013
Bearbeitet: Azzi Abdelmalek am 8 Mär. 2013

0 Stimmen

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!

Translated by