converting row and column
15 views (last 30 days)
Show older comments
Mohammad Sadegh Nasirianfar
on 27 Apr 2022
Commented: Mohammad Sadegh Nasirianfar
on 28 Apr 2022
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';
0 Comments
Accepted Answer
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)
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!