converting row and column

1 visualización (últimos 30 días)
Mohammad Sadegh Nasirianfar
Mohammad Sadegh Nasirianfar el 27 de Abr. de 2022
Comentada: Mohammad Sadegh Nasirianfar el 28 de Abr. de 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';

Respuesta aceptada

Torsten
Torsten el 28 de Abr. de 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

Más respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by