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

조회 수: 1 (최근 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
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 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