how to write a iterative code?
3 次查看(过去 30 天)
显示 更早的评论
Mohammad Sadegh Nasirianfar
2022-4-27
评论: Mohammad Sadegh Nasirianfar
2022-4-27
#MATLAB
I want to write a code and I don’t know with which command is better.
Put n=1
If Ic<1.64, n=0.5
If 1.64<Ic<3.3, n=(Ic-1.64)0.3+0.5
If Ic>3.3, n=1
Iterate until the change in delta-n<0.01
2 个评论
采纳的回答
David Hill
2022-4-27
Not sure what you are doing, but can find the n-vector all at once without iterating.
n=ones(size(lc));
n(lc<1.64)=.5;
n(lc>1.64&lc<3.3)=(lc(lc>1.64&lc<3.3)-1.64)*.3+.5;
f=find(diff(n)<.01,1);%first place where diff(n)<.01
4 个评论
David Hill
2022-4-27
fs = readmatrix('CPTU1.xlsx','Sheet','results','Range','E3:E2993');
qc = readmatrix('CPTU1.xlsx','Sheet','results','Range','D3:D2993');
sigmavo = readmatrix('CPTU1.xlsx','Sheet','results','Range','J3:J2993');
sigmaprimevo = readmatrix('CPTU1.xlsx','Sheet','results','Range','J3:J2993');
Q= (qc-sigmavo)/100.*(100./sigmaprimevo)^n;
F= fs./(qc-sigmavo)*100;
Ic= ((3.47-log10(Q)).^2+(1.22+log10(F)).^2).^0.5;
n=ones(size(Ic));
n(lc<1.64)=.5;
n(lc>1.64&lc<3.3)=(lc(lc>1.64&lc<3.3)-1.64)*.3+.5;
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Adding custom doc 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!