what can we use when we dont have value in a matrix instead of 0?

1 visualización (últimos 30 días)
i have a matrix of my data and i dont want to put 0 for the items that i dont have ...is there any other way?
  2 comentarios
Jonas
Jonas el 25 de Jun. de 2022
what about NaN or missing ?
arian hoseini
arian hoseini el 25 de Jun. de 2022
Editada: arian hoseini el 25 de Jun. de 2022
% relay awayBus closeBus Line Backup1 Backup2
Data= [1 1 2 1-6,1-3 14 nan
2 3 1 3-4 3 nan
3 4 3 4-5 4 nan
4 5 4 5-6 5 nan
5 6 5 6-1,6-2 7 6
6 2 6 2-1 1 nan
7 1 6 1-3,1-2 2 8
8 2 1 2-6 13 nan
9 1 3 1-6,1-2 14 8
10 3 4 3-1 9 nan
11 4 5 4-3 10 nan
12 5 6 5-4 11 nan
13 6 2 6-1,6-5 7 12
14 6 1 6-2,6-5 6 12];
Dimensions of matrices being concatenated are not consistent.
Error in ProtectionTask4_ArianHoseini (line 16)
Data= [1 1 2 1-6,1-3 14 NaN
i get this error is it because of 4th column

Iniciar sesión para comentar.

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 25 de Jun. de 2022
use nan?
data = rand(3);
data(2,3) = nan
data = 3×3
0.7049 0.8908 0.2471 0.2524 0.5020 NaN 0.4604 0.1822 0.3545
You could also use missing, especially if you are usure of the data type. The result is the same as nan for doubles.
data(3,2) = missing
data = 3×3
0.7049 0.8908 0.2471 0.2524 0.5020 NaN 0.4604 NaN 0.3545
c = ["a","b","c"];
c(1) = missing
c = 1×3 string array
<missing> "b" "c"
  5 comentarios
arian hoseini
arian hoseini el 25 de Jun. de 2022
for example for relay 1 i need to sumZ(1)+min(Z2(14),Z2(2))....the indexes u see are from my Data
Cris LaPierre
Cris LaPierre el 25 de Jun. de 2022
Sorry, but I don't see how Z relates to Data.
Also, it appears your outer for loop in Zone 1 is unnecessary (for k = 1 : 2). It runs the same code without any changes. You'd get the same results without it.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Etiquetas

Productos


Versión

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by