#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 件のコメント

Torsten
Torsten 2022 年 4 月 27 日
If lc does not change, n won't change either. Thus delta_n = 0.
Mohammad Sadegh Nasirianfar
Mohammad Sadegh Nasirianfar 2022 年 4 月 27 日
Ic changes. it is a matrix with one column and j rows and for each rows I have to control it

サインインしてコメントする。

 採用された回答

David Hill
David Hill 2022 年 4 月 27 日

0 投票

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 件のコメント

Mohammad Sadegh Nasirianfar
Mohammad Sadegh Nasirianfar 2022 年 4 月 27 日
Ic includes some materices with formulas. I wrote them as follows. Could you help me please about that?
a = input("what is the a Factor? ");
Num = input("what is the Number of the rows? ");
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');
for i=3:Num
n(i,1)=1;
Q(i,1) = (qc(i,1)-sigmavo(i,1))/100*(100/sigmaprimevo(i,1))^n;
F(i,1) = fs(i,1)/(qc(i,1)-sigmavo(i,1))*100;
Ic(i,1) = ((3.47-log10(Q(i,1)))^2+(1.22+log10(F(i,1)))^2)^0.5;
if Ic(i,1)>3.3
n(i,1)=1;
elseif Ic(i,1)<1.64
Mohammad Sadegh Nasirianfar
Mohammad Sadegh Nasirianfar 2022 年 4 月 27 日
I want to get all arrays of Ic and record them as Ic matrix
David Hill
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;
Mohammad Sadegh Nasirianfar
Mohammad Sadegh Nasirianfar 2022 年 4 月 27 日
thanks a lot.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

製品

リリース

R2022a

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by