matrices converted problem into code

I am trying to convert the matrices A 3by 3, B randsample 3by3, C 3by2 converted into the code then run script, which always got wrong answer said undefined solution or invalid expression, check for missing or extra character. Can any one help me out with this? Best regard!
B = [1.8,2.8,0.3;randsample(0.1:0.1:0.9,1),-0.9,0.0;-0.1,1.0,2.3];
A = [5,-4,2;1,5,4;-6,-1,-3];
C = [3,6;4,-5;5,0];
ans1=B+A;
ans2=A*B;
ans3=B*A;
no 'ans4'
Unrecognized function or variable 'no'.
no 'ans5'
no 'ans6'
ans7=A*C;
ans8=5*(A+B);
ans9=A+B;
ans10=(5*A)+(5*B);

답변 (1개)

Walter Roberson
Walter Roberson 2022년 8월 26일

0 개 추천

no 'ans4'
That would be a problem unless you happened to have defined a function no.m that accepted a character vector parameter.
Your code image has
ans4=
with nothing else on the end of the line. That is not valid syntax. If you want ans4 to exist but be empty, use either
ans4=[]
or
ans4=''

댓글 수: 2

Song
Song 2022년 8월 26일
I did, when I run script, Still not give me the correct answer sign with other question too.
Song
Song 2022년 8월 26일
Thank you for the advice, I just forgot to submit the assignment instead of just run script, all answers are correct now after submitted. Really appreciate your help.

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

카테고리

도움말 센터File Exchange에서 Functions에 대해 자세히 알아보기

질문:

2022년 8월 26일

댓글:

2022년 8월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by