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

2 次查看(过去 30 天)
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 个评论
arian hoseini
arian hoseini 2022-6-25
编辑:arian hoseini 2022-6-25
% 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

请先登录,再进行评论。

采纳的回答

Cris LaPierre
Cris LaPierre 2022-6-25
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 个评论
arian hoseini
arian hoseini 2022-6-25
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 2022-6-25
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

产品


版本

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by