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

3 vues (au cours des 30 derniers jours)
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 "

Réponses (2)

DGM
DGM le 15 Avr 2021
Modifié(e) : DGM le 15 Avr 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 commentaires
Hamada Alkhlif
Hamada Alkhlif le 15 Avr 2021
Modifié(e) : Hamada Alkhlif le 15 Avr 2021
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 le 15 Avr 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

Connectez-vous pour commenter.


VBBV
VBBV le 15 Avr 2021
Modifié(e) : VBBV le 15 Avr 2021
%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 commentaires
Hamada Alkhlif
Hamada Alkhlif le 15 Avr 2021
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 le 15 Avr 2021
Modifié(e) : VBBV le 15 Avr 2021
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

Connectez-vous pour commenter.

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by