Filter löschen
Filter löschen

Cant make my syms function into a fsolve function

4 Ansichten (letzte 30 Tage)
Mikkel Ibsen
Mikkel Ibsen am 4 Dez. 2017
Kommentiert: Walter Roberson am 4 Dez. 2017
Hi
Since I've found out that:
syms
Doesn't work in matlab gui, I need to change my code, and Im totally new at the fsolve function, and dont quite how it works, do I need to make a function file to make it work, I've look at many tutorials from mathworks but I still can't make my script work. This is what I need to make into a fsolve function:
example:
L = 12;
A = 0.3;
vaegt = 60;
Rcd = 250;
slag = (1:80)';
test = zeros(size(slag));
syms x
for h = 1:length(slag)
S0 = sqrt((2*x*vaegt*L)/(A*20000000));
kraeft = @(x)((1/1.5).*vaegt.*x./((0.2./slag(h))+0.5*S0))./1.3;
test(h) = solve(kraeft(x)==(Rcd),x);
end
If someone also see a way to make it calculate faster that would be nice :).

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 4 Dez. 2017
There is no problem using syms in a MATLAB GUI that is running interactively. There is only a problem if you attempt to compile or generate code.
Your system is effectively a quadratic, and has a pair of solutions:
(39/32000000000)*Rcd*(39*Rcd*slag*L +/- 39^(1/2)*(Rcd*slag*L*(39*L*Rcd*slag+640000000*A))^(1/2)+320000000*A)/(A*slag*vaegt)
There is no need to fsolve() at all.
  4 Kommentare
Mikkel Ibsen
Mikkel Ibsen am 4 Dez. 2017
The first one gives the right result, but why is there two solutions when syms only gives one?
And did you make matlab do the algebra simplification? or another program like Maple?
Walter Roberson
Walter Roberson am 4 Dez. 2017
>> syms L A vaegt Rcd slag x real
>> S0 = sqrt((2*x*vaegt*L)/(A*20000000));
>> S0
S0 =
((L*vaegt*x)/(10000000*A))^(1/2)
>> kraeft = @(x)((1/1.5).*vaegt.*x./((0.2./slag)+0.5*S0))./1.3;
>> solve(kraeft(x)==(Rcd),x)
Warning: Possibly spurious solutions.
> In symengine
In mupadengine/evalin (line 123)
In mupadengine/feval (line 182)
In solve (line 293)
Warning: Solutions are valid under the following conditions: slag*((39*L*Rcd*(320000000*A + 39*L*Rcd*slag -
390000000*Rcd*slag*((L*(640000000*A + 39*L*Rcd*slag))/(3900000000000000*Rcd*slag))^(1/2)))/(320000000000000000*A^2*slag))^(1/2) ~= -2/5 & 0
<= L*Rcd*slag*(640000000*A + 39*L*Rcd*slag);
slag*((39*L*Rcd*(320000000*A + 39*L*Rcd*slag + 390000000*Rcd*slag*((L*(640000000*A +
39*L*Rcd*slag))/(3900000000000000*Rcd*slag))^(1/2)))/(320000000000000000*A^2*slag))^(1/2) ~= -2/5 & 0 <= L*Rcd*slag*(640000000*A +
39*L*Rcd*slag). To include parameters and conditions in the solution, specify the 'ReturnConditions' value as 'true'.
> In solve>warnIfParams (line 508)
In solve (line 357)
ans =
(39*Rcd*(320000000*A + 39*L*Rcd*slag - 390000000*Rcd*slag*((L*(640000000*A + 39*L*Rcd*slag))/(3900000000000000*Rcd*slag))^(1/2)))/(32000000000*A*slag*vaegt)
(39*Rcd*(320000000*A + 39*L*Rcd*slag + 390000000*Rcd*slag*((L*(640000000*A + 39*L*Rcd*slag))/(3900000000000000*Rcd*slag))^(1/2)))/(32000000000*A*slag*vaegt)
At the moment I am not sure why the stepwise approach gives only one answer.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Formula Manipulation and Simplification finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by