converting row and column

1 回表示 (過去 30 日間)
Mohammad Sadegh Nasirianfar
Mohammad Sadegh Nasirianfar 2022 年 4 月 27 日
I have two questions:
  • why when I use this code evenif Ic and n are one column matrix, I recieve one row matrix for Kc?
  • How can I write the last line that in any array with that condition gives me NC for example?
Ic= real(((3.47-log10(Q)).^2+(1.22+log10(F)).^2).^0.5);
n(Ic<1.64)=.5;
n(Ic>1.64&Ic<3.3)=(Ic(Ic>1.64&Ic<3.3)-1.64)*.3+.5;
Kc(Ic<1.64) = 1.0;
Kc(Ic>1.64&Ic<2.6) = -0.403*(Ic(Ic>1.64&Ic<2.6)).^4+5.581*(Ic(Ic>1.64&Ic<2.6)).^3-21.63*(Ic(Ic>1.64&Ic<2.6)).^2+33.75*(Ic(Ic>1.64&Ic<2.6))-17.88;
Kc(Ic>2.6) = 'NC';

採用された回答

Torsten
Torsten 2022 年 4 月 28 日
By default, all one-dimensional vectors are row vectors.
But if you initialize Kc as a column vector, you'll get Kc a column vector:
Kc = zeros(numel(Ic),1);
...
If NC is a number, you can use
Kc(Ic>2.6) = NC
If you want to mark the positions in Kc where Ic is > 2.6, I suggest using NaN:
Kc(Ic>2.6) = NaN
  1 件のコメント
Mohammad Sadegh Nasirianfar
Mohammad Sadegh Nasirianfar 2022 年 4 月 28 日
thanks a lot!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by