Trying to make a goal seek like program using fsolve?
26 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Sean
am 9 Dez. 2025 um 0:50
Kommentiert: Walter Roberson
am 9 Dez. 2025 um 2:25
this is the code I currently have
clear all; close all; clc
f= @(x) Average1(x)-65;
engineering= 30; % Intiall estimate
function Average = Average1(engineering) % final grade
engineering = fsolve0(f,engineering)
calculus= 55;
chemistry= 76;
physics= 85;
english= 50;
a= calculus+chemistry+physics+english+engineering;
Average = a/5;
end
when I try to run it i don't get any errors or outputs.
I am trying to make a program that will take 4 veriable values and a wanted avereage of 65 to find the 5th veriable (in this case engineering) minimum value to get a overall average of 65. I am unsure of what am doing wrong I know that the answer for Engineering should be 59 to get a average of 65.
0 Kommentare
Akzeptierte Antwort
Torsten
am 9 Dez. 2025 um 2:04
clear all; close all; clc
f= @(x) Average1(x)-65;
engineering= 30; % Intiall estimate
engineering = fsolve(f,engineering)
f(engineering)
function Average = Average1(engineering)
calculus= 55;
chemistry= 76;
physics= 85;
english= 50;
a= calculus+chemistry+physics+english+engineering;
Average = a/5;
end
1 Kommentar
Walter Roberson
am 9 Dez. 2025 um 2:25
syms x
solve((55+76+85+50+x)/5 == 65)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!