Why doesn't plot change when I change some variables?

2 visualizaciones (últimos 30 días)
elham talvari
elham talvari el 31 de Dic. de 2021
Respondida: Image Analyst el 1 de En. de 2022
Hi. I have a plot which is plot my script properly. Now I want to change some parameters in my script but whenever I run the program, the plot doesn’t change and it shows old parameters and variables. For example I changed 1.5 to 20000 but the plot doesn't change.
[t z fz]=t_z_vectors(1.5, 15, 20, 10e-9, 100e-9); % arguments for FFT vector: fz, points_per_sin, oscillations, z0, amplitude
a=10e-9; % tip radius
L=50e-6; % half length tip (for finite dipole model
showsSNOM=0;
showPhase=1;
AddGraphs=1; % hold on at the end
%%%%%%%%%%%%%%%%%e%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%% calculations %%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
c0=299792458;
SingleValue=1e17; % n [cm^-3]
lambdaSI=c0./(0.2607*1e12);
materials
eps1=Drude(n*1e6, tau, m_eff, lambdaSI, epsL);
alpha=alphaFunc(a, epsTip);
scat1=polarizability2(alpha, eps1, def, a, L, z);
scat0=polarizability2(alpha, eps2, def, a, L, z);
[s1 phase1]=higher_harmonics(scat1,t,fz, hh);
[s0 phase0]=higher_harmonics(scat0,t,fz, hh);
if showsSNOM ==1
if AddGraphs==0
figure
end
switch norm
case 'contrast'
plot(n,(s1-s0)./s0*100, 'LineWidth',3);
ylabel('contrast');
extracted=(s1(idx)-s0)/s0*100;
case 'normalized'
plot(n,(s1./s0), 'LineWidth',3);
ylabel('normalized');
extracted=s1(idx)/s0;
case 'norm'
plot(n,(s1./max(s1)), 'LineWidth',3);
ylabel('norm');
extracted=s1(idx)/max(s1);
case 'free'
plot(n,s1, 'LineWidth',3);
ylabel('free');
extracted=s1(idx);Dirac fermion phenomena
end
set(gca, 'XScale', 'log')
xlabel('charge carrier density [cm^{-3}]')
end
if showPhase==1
if AddGraphs==0
figure
end
plot(n, phase1-phase0, 'LineWidth',3);
set(gca, 'XScale', 'log')
xlabel('charge carrier density [cm^{-3}]')
ylabel('phase')
phaseDiff=max(phase1)-min(phase1)
end
if AddGraphs==1
% hold on for adding new graphs
hold on
end
  3 comentarios
Voss
Voss el 31 de Dic. de 2021
Note that if AddGraphs is 1 (which it is here), then the plots will go into the current figure, which presumably is the same figure as where the previous plots went the last time (perhaps the last several times) you ran the script. Is it possible that several plotted lines exist in the same figure, from multiple runs, and the new one is indistinguishable from one of the old ones, so that nothing appears to change?
To check this possibility, please try running the script with AddGraphs set to 0 instead of 1, which will plot the results from each run in a new figure.
If the results still do not appear to change when changing the parameters, please provide definitions of the functions/scripts this script is calling, as well as variables the script is using which are not defined in the script itself, so that we can run it.
Image Analyst
Image Analyst el 1 de En. de 2022
@Walter, the limits are updated when you call hold on. It's just the line/curve that remains:
plot(1:10); % Limits are 1-10.
hold on
plot(30:200); % Limits are now 0-200 for y.
@elham talvari, what are the t_z_vectors(), Drude(), polarizability2(), alphaFunc(), etc. functions? We can't run your code until we get those functions.
Maybe call hold on then you check AddGraphs
if showsSNOM ==1
if AddGraphs == 0
figure % Create new figure.
else
% Use existing figure.
hold on;
end
and
if showPhase == 1
if AddGraphs == 0
figure % Create new figure.
else
% Use existing figure.
hold on;
end

Iniciar sesión para comentar.

Respuestas (1)

Image Analyst
Image Analyst el 1 de En. de 2022
Maybe call hold on then you check AddGraphs
if showsSNOM ==1
if AddGraphs == 0
figure % Create new figure.
else
% Use existing figure.
hold on;
end
and
if showPhase == 1
if AddGraphs == 0
figure % Create new figure.
else
% Use existing figure.
hold on;
end

Categorías

Más información sobre Choose and Parameterize Blocks en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by