how can I Compute the value of d for the following values of x , Outcome equation d=((34.63/x)-5.126)/2.54
1 view (last 30 days)
Show older comments
Is my code right i am beginner in matlab.
>>clc
>>clear
for x=[0.1000,0.1500,0.2000]
fprintf("\n\t%g\n",x)
else d=((34.63/x)-5.126)/2.54
disp ("ANSWER")
end
"OUTCOME WANTED RESULT "
0 Comments
Answers (2)
DGM
on 15 Apr 2021
Edited: DGM
on 15 Apr 2021
I have no idea what that code is intended to do, but if you just want to evaluate the expression all x:
x=[0.1000,0.1500,0.2000]
d=((34.63./x)-5.126)/2.54
I guess if you're trying to get it to display formatted results to console, you could do that as well.
for l=1:numel(x)
fprintf('\t%g\t%g\n',x(l),d(l))
end
7 Comments
Steven Lord
on 15 Apr 2021
Every time this line of code executes:
answer=[x' d']
it assigns a value to the variable named answer then displays the contents of that variable. If you just want to assign a value to the variable but not display it, end the line of code with a semicolon.
answer=[x' d'];
Then if you want to display it at the end of the code you can.
disp(answer) % or just plain
answer
See Also
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!