function[prob,flop]=Matlab(a,b)
a=[1,2,3];
b=[7,8,9];
if (length(a)~=length(b))
disp("it doesn't make sense");
end
prob=0;
flop=0;
for i=1:length(a)
prob=prob+a(i)*b(i);
flop=flop+2;
end
disp(prob);
disp(flop);
What is wrong with my code? it only run the...
50.1K
Verified Solution
Link Copied!
Question
Advance Math
function[prob,flop]=Matlab(a,b)
a=[1,2,3]; b=[7,8,9];
if (length(a)~=length(b)) disp("it doesn't make sense"); end
prob=0; flop=0;
for i=1:length(a) prob=prob+a(i)*b(i); flop=flop+2; end disp(prob); disp(flop);
What is wrong with my code? it only run the disp(prob) and itdoesn't run the disp(flop)
here is what I got
ans =
50
However, if I take % for the function line, it shows
50
6
Answer & Explanation
Solved by verified expert
3.9 Ratings (349 Votes)
function dummyclcclear alla123b789probflopMatlababfunctionprobflopMatlababif lengthalengthbdispit
See Answer
Get Answers to Unlimited Questions
Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!
Membership Benefits:
Unlimited Question Access with detailed Answers
Zin AI - 3 Million Words
10 Dall-E 3 Images
20 Plot Generations
Conversation with Dialogue Memory
No Ads, Ever!
Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!