How can I plot cornering stiffness using GUI ?

11 views (last 30 days)
Turboduff
Turboduff on 27 May 2015
Commented: Adam on 2 Jun 2015
Hello Everyone
I am Koushik, a young automotive engineering graduate with keen interest in vehicle dynamics.I have just started learning MATLAB on my own.I wanted to create a plot for Cornering stiffness of a Tyre ( Lateral Force Vs Slip Angle).So,I created a GUI and I am struggling to plot the graph.I have attached the .m file and the .fig file for your reference.Kindly guide me on plotting this.

Answers (1)

Adam
Adam on 27 May 2015
You can use e.g.
handles.Fz = str2double(get(hObject,'String'));
in your callback (e.g. the Fz0_Callback)
then in your plot callback use
handles.Fz
instead of just variables that don't exist in the scope of the plot function.
Or in the plot function you can get the values directly from the ui controls using the same manner, but without needing to save them on the handle struct.
  2 Comments
Turboduff
Turboduff on 2 Jun 2015
Edited: Turboduff on 2 Jun 2015
Hi Adam
First of all thank you very much for your answer and Sorry for the late response.I tried it, but still it shows an error.
I guess I messed up somewhere.I have attached the updated .m file for your reference.
In the calculation process there comes point, where the MATLAB takes a decision based on the value of alphay .
If alphay is positive then sgn(alphay) should take the value 1 else it must take the value -1.
I get an error here like this
" Attempted to access sign(40634.4); index must be a positive integer or logical.
Error in cornering_stiffness_plot>plot_Callback (line 642) sign(alphay)= 1;
Error in gui_mainfcn (line 95) feval(varargin{:});
Error in cornering_stiffness_plot (line 43) gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)cornering_stiffness_plot('plot_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback* "
Looking forward for your response.
Regards Koushik
Adam
Adam on 2 Jun 2015
There are a few things wrong with this piece of code:
if alphay>0
sign(alphay)= 1;
else
sign(alphay)= -1;
  1. You are using alphay as an array index despite it not being an integer (as the error says).
  2. You are overwriting (or hiding, rather) a builtin function by assigning to an array called 'sign'.
  3. The builtin function that you are overwriting would give exactly the answer you want if you were to simply call it where needed rather than trying to re-implement it yourself by assigning values to an array.
If you were to just remove the above lines of code then the call to sign(alphay) on the subsequent line should work fine by calling the builtin function rather than an array you are trying to create to hide the function.

Sign in to comment.

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!