Can't solve function to variable.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Cédric Moers
le 16 Sep 2016
Commenté : Cédric Moers
le 17 Sep 2016
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/156416/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/156417/image.png)
Thank you!
0 commentaires
Réponse acceptée
Walter Roberson
le 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.
Plus de réponses (1)
Patrick Aoun
le 16 Sep 2016
Modifié(e) : Patrick Aoun
le 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 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!