Clear Filters
Clear Filters

Can't solve function to variable.

7 views (last 30 days)
Hi Matlab users,
I'm an engineering student currently working on my thesis.
I'm quite new to Matlab and I can't seem to find a solution to my problem. It is as follows: I want to solve this equasion to 'vt', but I tried everything in my knowledge of Matlab without any succes. I also use the MathCAD software for my studies and that doesn't seem to work either (free version). I used functions like solve, root functions, evaluate .. all that seemed usable to me. I might use them incorrectly, but always the same result: that it can't solve the function or that no results have been found. That's why I'm asking you guys for help. I have no knowledge of real numeric methods and have also tried solving it by hand. Only when I assign numbers to the variables except to 'vt' it seems to give results.
Is it possible that this equasion isn't solvable using only symbols? All parameters are variable but known, except for 'vt'.
It is for a system that does a given acceleration starting from a given speed and then a given decceleration to a given position and ending speed within a given time interval. The only parameter I want to know is 'vt' as v-terminus, the terminal speed of the servo drive, to get to the position in time. It's for generating an S-curve from a set of linear functions (position-time) given by the user in a motion controlling tool.
this is the equation in text base:
eqn := ((vt-vo)/a)*(vo+((vt-vo)/2))+vt(tt-((vt-vo)/a)-((ve-vt)/a))+((ve-vt)/a)*(ve+(ve-vt)/2)-tt*vgem = 0
below it's more graphic:
Thank you!

Accepted Answer

Walter Roberson
Walter Roberson on 16 Sep 2016
You missed a multiplication operator
eqn := ((vt-vo)/a)*(vo+((vt-vo)/2))+vt*(tt-((vt-vo)/a)-((ve-vt)/a))+((ve-vt)/a)*(ve+(ve-vt)/2)-tt*vgem = 0
You had vt(tt- etc) instead of vt*(tt- etc .
With the change to insert the multiplication there is no difficulty.
  1 Comment
Cédric Moers
Cédric Moers on 17 Sep 2016
Wow, I really feel stupid now.. Fixing this and using solve(...) got me the answer I wanted. Thank you very much!

Sign in to comment.

More Answers (1)

Patrick Aoun
Patrick Aoun on 16 Sep 2016
Edited: Patrick Aoun on 16 Sep 2016
Wait... while rereading your question I noticed something.
Are you trying to solve it analytically? Like, without setting a value for the variables?
MATLAB doesnt do that (Wolfram Alpha might though). All variables apart from vt have to have a value. Your code has to start with:
vo = 10
tt = 5
a = 2
... etc.
If I misunderstood and you want to solve it numerically keep reading bellow:
________________________
If you have the optimisation toolbox, try using fminsearch:
1. Change the function so that it's in the form : 0 = ABS(...) (ABS here means absolute) 2. fminsearch the ABS(...) of the equation. Using v_t as the variable and defining the rest.
Be aware that there might be multiple solutions to your equation. fminsearch will return one, depending on x0.
Basically:
fminsearch( @(vt) abs( ((vt-vo)/a)*(vo+((vt-vo)/2))+vt(tt-((vt-vo)/a)-((ve-vt)/a))+((ve-vt)/a)*(ve+(ve-vt)/2)-tt*vgem ) , x0)
You choose x0. Try multiple ones.
  3 Comments
Cédric Moers
Cédric Moers on 16 Sep 2016
Edited: Cédric Moers on 16 Sep 2016
Thank you for your fast response Patrick and Stephen! I was in a hurry when posting this question, so the problem was a bit quick formulated.
What I actually want as an outcome is a symbolic formula that gives v_t in function of the other variables, because it needs to be calculated using different values. Also I can't use the functions like 'solve' in MathCAD, because it's a free version, but I can just fill in formulas.
that's why I need something like this:
x*v_t + y*v_t² + z = 0 to become like this: v_t = ...
So it's basically finding a the roots of the function.
That's why I also tried some of the root functions and also doing it by hand with the standard second degree function formulas etc.. But the results I got from this were faulty.
I really need that symbolic formula, because I want to place it in the document I made in MathCAD. I also have a few pages of other calculations for the system, so it would take long to copy it over. It needs to become a sort of a sheet, which I can use in the future, but only changing a few parameters at the beginning of the document.
MUpad is the only thing I have used from Matlab in the past, so it was also the first I tried. Should have mentioned that.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!