Adding the results of several pcolor graphs...

4 views (last 30 days)
Hello everyone: I am having difficulties, as I have made a program which calculates some values which it later represents in a pcolor graph (I will paste the code below). The values are calculated one by one in terms of two variables (n_re and n_im) and the color map just indicates the mean difference between my theoretical Contrast (Cteo) and my experimental Contrast (Cexp). The problem is that even though it obtains the correct answers each time (I've tried calculating just one value at a time) if done individually, it only displays in the pcolor graph the last value calculated if a series of values are used (loaded from a table experimental_values_M2612)I need some function or an idea of how I could manage to get each individual result obtained by the program and display it as one overall pcolor graph where I can see a real minimum for ALL my results instead of just one at a time.
function [] = mapa
m=30;
n_re=linspace(1,6,m);
n_im=linspace(0,5,m);
% z=zeros(m,m);
global lambda0;
lambda0=500;
% global z;
% z=[m,m];
load('C:\Users\Weinberg\Desktop\Prueba matlab\Prueba pcolor_V1\Samples\experimental_values_M2612')
tic
for v=1:20
d=Experimental_values(v,1);
Cexp=Experimental_values(v,3);
for i=1:m
for j=1:m
n=n_re(i)+1i*n_im(j);
z(i,j)=cx2(lambda0,d,n,Cexp);
end
end
pcolor(n_re,n_im,z);shading interp; colormap(jet);
toc
end
end
function [x2]=cx2(lambda0,d,n,Cexp)
x2=(Cexp-Cteo(lambda0,d,n)).^2;
end
function [C]=Cteo(lambda0,d,n)
nair=1;
dSiO2=285;
nSi=2
nSiO2=2
%calcular el contraste teorico
mSiO2=Sij(nair,nSiO2)*Pj(nSiO2,dSiO2,lambda0)*Sij(nSiO2,nSi);
mflake= Sij(nair,n)*Pj(n,d,lambda0)...
*Sij(n,nSiO2)*Pj(nSiO2,dSiO2,lambda0)*Sij(nSiO2,nSi);
rSiO2=abs(mSiO2(2,1)/mSiO2(1,1))^2;
rflake=abs(mflake(2,1)/mflake(1,1))^2;
C =(rflake-rSiO2)/(rflake+rSiO2);
end
Any help will be greatly appreciated, and thank to anyone that can help me in advance. Guillermo
  6 Comments
Guillermo Lopez
Guillermo Lopez on 20 Apr 2012
First of all, thanks for your answers.
The images will be these:
http://imageshack.us/photo/my-images/207/examplev1.png/
http://imageshack.us/photo/my-images/207/examplev3.png/
http://imageshack.us/photo/my-images/207/examplev8.png/
http://imageshack.us/photo/my-images/207/examplev18.png/
Each of these are with different values for v (v=1,v=3,v=8 and v=18) each meaning a different row in my data table (v=row number in data table)
The blue regions in the images is the minimum at which the difference between my experimental contrasts (Cexp) and my theoretical contrasts (Cteo) is minimum whilst the red areas are the points at which the difference between the theoretical and experimental are most different. As you can see one at a time each graph is displayed correctly, but when done inside a loop, the program only displays the last one that has been calculated.
The best case scenario would be a program that allows me to analyze all the images (for instance adding each individual point's x2 value (which is what is represented with the color)so that in the end the minimum region in the last graph would be an addition of all the minimum areas from all previous graphs.
Thanks again very much to you all
Guillermo Lopez
Guillermo Lopez on 20 Apr 2012
The table of data can be downloaded from
http://www.mediafire.com/?q36jmcxq3nr0cg8
The only thing is that the load folder must be changed in the code from:
load('C:\Users\Weinberg\Desktop\Prueba matlab\Prueba pcolor_V1\Samples\experimental_values_M2612') and change it to whatever folder.

Sign in to comment.

Answers (2)

Jan
Jan on 19 Apr 2012
See doc hold. I assume a "hold('on')" behind the pcolor command will fix the axes to draw in.
Another idea would be to create the axes explicitely and setting the 'NextPlot' property:
AxesH = axes('NextPlot', 'add');
for v=1:20
...
pcolor(..., 'Parent', AxesH);
  4 Comments
Jan
Jan on 19 Apr 2012
Do you draw the PCOLOR areas to the same location? Then of course the conceal eachother.
Guillermo Lopez
Guillermo Lopez on 20 Apr 2012
I dont use pcolor anymore, I am using Imagesc as Image analyst suggested and although the result is for practical purposes the same (visually) I am obtaining data and not just an image

Sign in to comment.


Image Analyst
Image Analyst on 19 Apr 2012
I assume you know that pcolor does not color the "tiles" according to what their value is, like image, imagesc, or imshow does. If you didn't know that, then switch to one of those functions.
  5 Comments
Image Analyst
Image Analyst on 19 Apr 2012
You already have the matrix as a variable. You needed that before you displayed it. If you want to save a picture of the figure window, use export_fig (in the Mathworks File Exchange).
Guillermo Lopez
Guillermo Lopez on 20 Apr 2012
I put up online the data table, and some images...hope it makes it easier for any help. Thank you very much.

Sign in to comment.

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!