How do I use IF-loops with plot_handles?
Mostrar comentarios más antiguos
I'm having a bit of a problem to integrate the if-loop with plot handles. So the program I'm writing has this structure:
It has this menufile in which you choose what you want to do (This is only a small part of it):
case 1
plot_handles = createPlot(plot_handles);
case 2
changeWidth(plot_handles);
In case 1 you'll be able to index a figure and write the function which is plotted and you're being returned to the menu.
function plot_handles = createPlot(plot_handles)
clc
try
figureid = input('Input figure-ID: ');
func= input('Input function f(x): ','s');
figure(figureid);
h=ezplot(func);
plot_handles(figureid)=h;
catch
lasterr
error('Nonvalid function!');
end
end
Back in the menu I enter case 2 where the thought is that it'll ask you which figure you want to edit.Once you've choosen that you're supposed to be able to edit that figures' linewidth:
function changeWidth(plot_handles)
figureid = input('Input figure-ID: ');
h = plot_handles(figureid);
if exist(figureid)== 0 % Here's the problem, I don't know how to test if ...
% the ID is correct or not.
error('Invalid figure-ID')
else
width=input('Input new width: ');
set(h, 'linewidth', width)
end
The problem is that I don't know how to check if figure-ID is correct in the IF-loop, elsewhere I want the errormessage so be written out.
Would really appreciate some help!
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!