Silly question about 2 column matrix

조회 수: 1 (최근 30일)
A Poyser
A Poyser 2023년 6월 6일
댓글: John D'Errico 2023년 6월 6일
It is my understanding that
a = [1 3 5; 2 4 6; 7 8 10]
a = 3×3
1 3 5 2 4 6 7 8 10
yet
AL01-SIGMA09 = [1183.885678 512.1;
Incorrect use of '=' operator. Assign a value to a variable using '=' and compare values for equality using '=='.

Error in connector.internal.fevalMatlab

Error in connector.internal.fevalJSON
568.8329716 512.1;
417.7853247 512.1;
200.7327245 512.1;
38.95699064 512.1;
19.83313269 512.1;
14.56665171 512.1;
8.010756815 512.1]
gives me this error, I can't see the difference. Can someone explain how I create a two column matrix from this data.
Thanks in advance
Alex

채택된 답변

Tushar
Tushar 2023년 6월 6일
Hello A Poyser,
Please note that the error you are getting is not due to the "=" or "==" operator but it is simply because you cannot use hyphens in variable naming in MATLAB. Change the variable name and you can create the matrix using the very same syntax you provided :) Instead try using underscore.
AL01_SIGMA09 = [1183.885678 512.1;
568.8329716 512.1;
417.7853247 512.1;
200.7327245 512.1;
38.95699064 512.1;
19.83313269 512.1;
14.56665171 512.1;
8.010756815 512.1]
AL01_SIGMA09 = 8×2
1.0e+03 * 1.1839 0.5121 0.5688 0.5121 0.4178 0.5121 0.2007 0.5121 0.0390 0.5121 0.0198 0.5121 0.0146 0.5121 0.0080 0.5121
  댓글 수: 2
A Poyser
A Poyser 2023년 6월 6일
Tushar, yes I realised as soon as I saw the answer from VBBV. Thanks for the help.
John D'Errico
John D'Errico 2023년 6월 6일
In fact, really this answer gets to the correct point of the problem best. Sadly, it was not accepted as the correct answer. That is a flaw of Answers. But at least I can give it an up-vote. Such is life.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

VBBV
VBBV 2023년 6월 6일
편집: VBBV 2023년 6월 6일
From the below error, its visible that AL01 & SIGMA09 are both scalar variables and difference between them is also scalar. They have different dimensions when compared with matrix present in RHS & not possible to equate them
AL01 = 3;
SIGMA09 = 2;
AL01-SIGMA09 = [1183.885678 512.1;
Incorrect use of '=' operator. Assign a value to a variable using '=' and compare values for equality using '=='.
568.8329716 512.1;
417.7853247 512.1;
200.7327245 512.1;
38.95699064 512.1;
19.83313269 512.1;
14.56665171 512.1;
8.010756815 512.1]
  댓글 수: 1
A Poyser
A Poyser 2023년 6월 6일
Ahhhhh. Silly me. It is a naming error. It's one array AL01-SIGMA09 should be AL01_SIGMA09.
Thanks so much.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by