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'
no 'ans5'
no 'ans6'
ans7=A*C;
ans8=5*(A+B);
ans9=A+B;
ans10=(5*A)+(5*B);
回答(1 个)
Walter Roberson
2022-8-26
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=''
类别
在 帮助中心 和 File Exchange 中查找有关 Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!