필터 지우기
필터 지우기

problem with for loop

조회 수: 1 (최근 30일)
itsik
itsik 2011년 5월 18일
hello i try to make a for loop but i need the jumps between the numbers will be in factor of 10 lets say there is a for loop like that: for i=1:5
so i need to make
for i=10,100,1000,10000
but it wont work maybe someone know what to do? thanks alot!

채택된 답변

Matt Fig
Matt Fig 2011년 5월 18일
for ii = logspace(1,5,5)
% Do stuff here.
end

추가 답변 (4개)

Oleg Komarov
Oleg Komarov 2011년 5월 18일
for ii = 10.^(1:5)

Sean de Wolski
Sean de Wolski 2011년 5월 18일
w=0:60*(10^6/4096)+1:60*10^6 ; % [Hz]
zl=50 ; % [ohm]
zs=50 ; % [ohm]
R=1.9884 ; % [ohm/meter]
G=0.01686*10^-9 ; % [mho/meter]
C=0.13394*10^-9 ; % [farad/meter]
L=362.81*10^-9 ; % [henrry/meter]
zc=sqrt((R+1j.*w.*L)./(G+1j.*w.*C)); % characteristic impedance
gama=sqrt((R+1j.*w.*L).*(G+1j.*w.*C));
l_change = 10.^(1:5);
%Engine
lg = (l_change')*gama;
aa=cosh(lg);
bb=bsxfun(@times,zc,sinh(lg));
cc=bsxfun(@times,(1./zc),sinh(lg));
dd=cosh(lg);
H_change= (zl./((aa.*zl)+bb+(cc.*zl.*zs)+(dd.*zs)));
EDITED: per Oleg's comment and full data set.
  댓글 수: 1
Oleg Komarov
Oleg Komarov 2011년 5월 18일
Doesn't work with complete code, bsxfun is needed

댓글을 달려면 로그인하십시오.


itsik
itsik 2011년 5월 18일
[EDIT: Wed May 18 18:21:13 UTC 2011 - Merged Answers - MKF]
ok i tried it but it still doesnt work this is the code maybe someone know thanks again!!!
w=0:60*(10^6/4096)+1:60*10^6 ; % [Hz]
zl=50 ; % [ohm]
zs=50 ; % [ohm]
R=1.9884 ; % [ohm/meter]
G=0.01686*10^-9 ; % [mho/meter]
C=0.13394*10^-9 ; % [farad/meter]
L=362.81*10^-9 ; % [henrry/meter]
zc=sqrt((R+j.*w.*L)./(G+j.*w.*C)); % characteristic impedance [ohm]
gama=sqrt((R+j.*w.*L).*(G+j.*w.*C));
l_change = 10.^(1:5);
for length=l_change
aa=cosh(gama.*l_change);
bb=zc.*sinh(gama.*l_change);
cc=(1./zc).*sinh(gama.*l_change);
dd=cosh(gama.*l_change);
H_change= (zl./((aa.*zl)+bb+(cc.*zl.*zs)+(dd.*zs)));
end
  댓글 수: 6
Matt Fig
Matt Fig 2011년 5월 18일
@Oleg and Andy,
Also, as people comment on non-Answers, it is harder for the editors to move the answers to the appropriate comments section...
Perhaps this will be fixed in the future, but right now editors cannot edit comments, only delete them, and cannot change an answer to a comment with the same authorship...
Andy
Andy 2011년 5월 18일
@Oleg, thanks!
@Matt, good to know. In the future, I'll make this sort of comment on the main question so that the 'answer' can be edited appropriately.

댓글을 달려면 로그인하십시오.


itsik
itsik 2011년 5월 18일
thank u very much for your help!!!!!!!!

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by