converting row and column

1 view (last 30 days)
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';

Accepted Answer

Torsten
Torsten on 28 Apr 2022
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

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!