draw a control plot for a function

6 Ansichten (letzte 30 Tage)
debabrat
debabrat am 15 Apr. 2014
Kommentiert: debabrat am 16 Apr. 2014
hello everyone, I need to generate a contour plot for the following code:- e=2.71828; dt=.01; A=-1; B=1; a=cell(12,12); data=zeros(1,220) for i=1:20 eps=i for j=0:0.1:1 beta=j for t=0:0.01:1.9 t=t+dt xp=0.1 fxp=eps*xp fz0=1/1+power(e,beta*(-t)) fzi=A+(B-A)*rand(1,12) for ii=1:12 for jj=1:12 if ii==jj a2(ii,jj)=fzi(jj) else a2(ii,jj)=0; end end end s=fxp*fz0 *a2 x=xp+(s*dt) xp=x end p=abs(fft(x)) p=p.^2 ne=max(p(1:10)) ne1=max(p(10:30)) ne2=max(p(80:120)) end end figure (1) [C,h]=contour(eps,beta,ne,'linewidth',2) figure (2) [C,h]=contour(eps,beta,ne1,'linewidth',2) figure (3) [C,h]=contour(eps,beta,ne2,'linewidth',2)
ne,ne1,ne2 is holding the value only for the last loop..but i need all the values of ne,ne1,ne2.. what should i do..please help....

Akzeptierte Antwort

A Jenkins
A Jenkins am 15 Apr. 2014
You want to store ne, etc as a matrix of the size of your loops, so it would be ne(i,j), etc:
e=2.71828;
dt=.01;
A=-1; B=1;
a=cell(12,12);
data=zeros(1,220);
eps=1:20;
beta=0:0.1:1;
kk=0;
for i=1:length(eps)
for j=1:length(beta)
for t=0:0.01:1.9
t=t+dt;
xp=0.1;
fxp=eps(i)*xp ;
fz0=1/1+power(e,beta(j)*(-t));
fzi=A+(B-A)*rand(1,12);
for ii=1:12
for jj=1:12
if ii==jj
a2(ii,jj)=fzi(jj);
else
a2(ii,jj)=0;
end
end
end
s=fxp*fz0 *a2;
x=xp+(s*dt);
xp=x;
end
p=abs(fft(x));
p=p.^2;
ne(i,j)=max(p(1:10));
ne1(i,j)=max(p(10:30));
ne2(i,j)=max(p(80:120));
end
end
figure(1)
[C,h]=contour(eps,beta,ne','linewidth',2)
figure(2)
[C,h]=contour(eps,beta,ne1','linewidth',2)
figure(3)
[C,h]=contour(eps,beta,ne2','linewidth',2)
  1 Kommentar
debabrat
debabrat am 16 Apr. 2014
Thank you very much A Jenkins... It works nicely..

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by