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

1 回表示 (過去 30 日間)
arian hoseini
arian hoseini 2022 年 6 月 25 日
コメント済み: Cris LaPierre 2022 年 6 月 25 日
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 件のコメント
Jonas
Jonas 2022 年 6 月 25 日
what about NaN or missing ?
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 Center および File ExchangeLogical についてさらに検索

タグ

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by