converting row and column

조회 수: 17 (최근 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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by