how can I Compute the value of d for the following values of x , Outcome equation d=((34.63/x)-5.126)/2.54

2 次查看(过去 30 天)
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 "

回答(2 个)

DGM
DGM 2021-4-15
编辑:DGM 2021-4-15
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 个评论
Hamada Alkhlif
Hamada Alkhlif 2021-4-15
编辑:Hamada Alkhlif 2021-4-15
actually iam getting the answer right but it look deferent .
answer after submitte above code :
>> Untitled3
0.1 134.32
answer =
0.1000 134.3205
0.1500 88.8743
0.2000 66.1512
0.15 88.8743
answer =
0.1000 134.3205
0.1500 88.8743
0.2000 66.1512
0.2 66.1512
answer =
0.1000 134.3205
0.1500 88.8743
0.2000 66.1512
>>
i just want the code to give 1 answer like this
answer =
0.1000 134.3205
0.1500 88.8743
0.2000 66.1512
how can i modify the last code @DGM ?
Steven Lord
Steven Lord 2021-4-15
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

请先登录,再进行评论。


VBBV
VBBV 2021-4-15
编辑:VBBV 2021-4-15
%true
d = [];
for x=[0.1000,0.1500,0.2000]
d=[d ((34.63/x)-5.126)/2.54];
disp ("ANSWER");
end
x=[0.1000 0.1500 0.2000];
fprintf("\t%4g\t\t%4g\n",[x;d])
  2 个评论
Hamada Alkhlif
Hamada Alkhlif 2021-4-15
this is almost the wanted code just is that the x values not in 4 decimals and it the code out put display 3 words of answers ,it required only one .
VBBV
VBBV 2021-4-15
编辑:VBBV 2021-4-15
d = [];
for x=[0.1000,0.1500,0.2000]
d=[d ((34.63/x)-5.126)/2.54];
end;
disp ("ANSWER");
x=[0.1000 0.1500 0.2000];
fprintf("\t%.4f\t\t%.4f\n",[x;d])
Try this

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by