To find value of variable using iteration
Ältere Kommentare anzeigen
Hello,
At first I need to generate a random number that was done using rand command.
Then I have to use iteration such that it satisfies a certain relation. I used while loop but it is not stopping.
x = rand(1,1);
while 350-12.9-x-32.4498 ~= 0
x= x+ 0.0001
end
The problem is other values can also change drastically so it would take a long time to find values. Any other suggestions?
Akzeptierte Antwort
Weitere Antworten (1)
Awais Saeed
am 28 Aug. 2021
Bearbeitet: Awais Saeed
am 28 Aug. 2021
What is your goal exactly? Do you want to find the value for x where the result is zero? You can find the roots using solve
syms x
vpa(solve(350-12.9-x-32.4498 == 0,x))
1 Kommentar
Dhananjay Singh
am 28 Aug. 2021
Kategorien
Mehr zu Error Functions finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!