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);

Antworten (1)

Walter Roberson
Walter Roberson am 26 Aug. 2022

0 Stimmen

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 Kommentare

Song
Song am 26 Aug. 2022
I did, when I run script, Still not give me the correct answer sign with other question too.
Song
Song am 26 Aug. 2022
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Functions finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 26 Aug. 2022

Kommentiert:

am 26 Aug. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by