??? Error using ==> plot Vectors must be the same lengths.

4 views (last 30 days)
Hi,
I'm experiencing this error when handling a function of my axes
??? Error using ==> plot Vectors must be the same lengths.
Error in ==>
BrakeDiscAnalysis>Plot_pushbutton_Callback at 595 plot(forceAxes,x,y,'-r')
How can I rectify this error? Below's my script
function Plot_pushbutton_Callback(hObject, eventdata, handles)
global ForceAxes
Df = str2num(get(handles.FrontRo_text,'string'));
forceAxes = ForceAxes;
%axes(ForceAxes);
df = linspace(0,Df(1),80)
x = df/Df(1);
y = (1+x)/2;
hold on
plot(forceAxes,x,y,'-r')
Thanks

Accepted Answer

Image Analyst
Image Analyst on 30 Nov 2012
What is the global variable ForceAxes? When you pass ForceAxes into plot(), it expects it to be a handle, like a floating point number that is the ID number of the axes. It's probably not that. Who knows what it is? Why don't you just pass in the handles to the axes directly:
plot(handles.forceAxes, x, y, 'r-');

More Answers (2)

dpb
dpb on 30 Nov 2012
Apparently ForceHandle isn't a valid axis handle; hence plot() thinks the x,y data are the handle and the x vector.
Use ishandle to test if it is a valid graphics handle;
doc ishandle % and links for more details
--
  2 Comments
Image Analyst
Image Analyst on 30 Nov 2012
Hey dpb, welcome to the Answers forum! I think you'll find a lot more activity here than the newsgroup, plus the ability to edit posts is a MAJOR benefit over the newsgroup. I'm sure you'll be adding a wealth of knowledge here like you did to the newsgroup.
dpb
dpb on 30 Nov 2012
I don't know, IA, TMW is going to have to improve the UI significantly I think before I'm likely to do much here--just too clunky/overhead-intensive for old text-newsreader-patterned geezer. :(
I've made some suggestions for improvement to TMW and have had/have a sorta' intermittent offline conversation w/ some of the staff and have promised as part of that to at least try some. So, I'm trying but it certainly is trying (my patience, that is) :(
Why, if they wanted a portal of their own they didn't start w/ a newsgroup-like interface product and add the fluff around it instead of trying to reinvent the wheel around a database is beyond my ken.
It takes at least an order of magnitude longer time to do less than I did/do at cs-sm and I don't see probably a tenth of the threads here whereas I try to at least skim virtually all there simply because of the time/effort required to keep paging back/forth, back/forth, back/forth...

Sign in to comment.


J
J on 1 Dec 2012
Thank you, it works. Thanks IA and dpb for your explanation ,it helps me to understand more about GUI. :)

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!