index must be a positive integer or logical.
2 ビュー (過去 30 日間)
古いコメントを表示
c1=3.29;
c2=9.90;
c3=0.77;
c4=0.20;
Ln=zeros(1,length(t));
for n=1:1:100;
for t=0:-0.1:-1;
Ln(t)=-(c1+c2*log(n)*log(-t))-(c3+c4*log(n));
semilogx(n,Ln(t));
end
end
I really want t to count negative, what am I supposed to do??
3 件のコメント
Marta Salas
2014 年 3 月 11 日
編集済み: Marta Salas
2014 年 3 月 11 日
You're going to define an index that it's not related with t but with the size of t. However I don't understand what you are trying to plot there. Which is the result you are expecting from that code? what do you want to plot on semilogx?
採用された回答
Chris C
2014 年 3 月 11 日
I'm still not reall clear on what you're looking for, but try this version of Marta's code...
c1=3.29;
c2=9.90;
c3=0.77;
c4=0.20;
t = linspace(0,-1,10); %definition of t vector
n = linspace(1,100);
Ln=zeros(length(t),length(n));
for i=1:length(t)
for j = 1:length(n);
Ln(i,j)= -(c1+c2*log(n(j))*log(-t(i)))-(c3+c4*log(n(j)));
end
semilogx(n,Ln(i,:))
hold on
end
2 件のコメント
その他の回答 (2 件)
dpb
2014 年 3 月 11 日
Keep the time as associated independent vector of same length as the solution vector but numbered from 1:N instead of trying to use it as an index.
0 件のコメント
Marta Salas
2014 年 3 月 11 日
A solution is this:
c1=3.29;
c2=9.90;
c3=0.77;
c4=0.20;
Ln=zeros(1,length(t));
t= 0:-0.1:-1; %definition of t vector
for n=1:1:100;
for i=1:length(t);
Ln(i)= -(c1+c2*log(n)*log(-t(i)))-(c3+c4*log(n));
semilogx(n,Ln(i));
end
end
Take into account semilogx(n,Ln(i)) is plotting a point. is this the right solution?
7 件のコメント
dpb
2014 年 3 月 11 日
Well, read and do a little thinking on your own...fix the upper limit on the for loop to be 1:length(n)
参考
カテゴリ
Help Center および File Exchange で Detection についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!