Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

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

Asked by J on 30 Nov 2012

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

0 Comments

J

Products

No products are associated with this question.

3 Answers

Answer by Image Analyst on 30 Nov 2012
Accepted answer

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-');

0 Comments

Image Analyst
Answer by 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 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 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...

dpb
Answer by J on 1 Dec 2012

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

0 Comments

J

Contact us