plot graph to GUI from m-file

10 visualizzazioni (ultimi 30 giorni)
Teemu Juujärvi
Teemu Juujärvi il 15 Set 2015
Commentato: Adam il 18 Set 2015
Hi,
I have succesfully plotted some graphs to GUI from m-file by using handle (in m-file) like this: plot(GUI_handle, variable, '-', 'color', [ 104 113 122 ]/255, 'linewidth', 2 ); But now I want to plot graph from two variables like this: plot(GUI_handle, variable1, variable2, '-', 'color', [ 104 113 122 ]/255, 'linewidth', 2 ); This should plot x-y graph from variable values, but it gives error message: Error using plot Vectors must be the same length.
Variables have the same length and normal plot draws graph like it should: figure(1) plot (variable1, variable2) How can I get this plot to GUI?
Teemu

Risposte (2)

Tim Jackman
Tim Jackman il 17 Set 2015
I can't seem to reproduce this. If I create a simple GUI with an axes object in it, I can plot an x vector or an x and y vector just fine as long as I have specified the handle to the axes object correctly (for me, the handle for the axes object was handles.axes1).
Could this issue be related to the handle you are supplying to the plot command?

Adam
Adam il 17 Set 2015
The first argument to plot is either an axes handle or the x data. I'm not sure why your original code works, to be honest, as you seem to imply you are passing in the GUI handle rather than the axes handle.
Probably in the second case it is trying to take your GUI handle as the x data and the 2nd argument as the y data.
  2 Commenti
Teemu Juujärvi
Teemu Juujärvi il 17 Set 2015
Yes it takes the handle as x data. How I can avoid that or draw it correctly?
Adam
Adam il 18 Set 2015
Just pass the axes handle instead of the gui handle

Accedi per commentare.

Categorie

Scopri di più su Specifying Target for Graphics Output in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by