0

if-loop を plot_handles と統合するのに少し問題があります。したがって、私が書いているプログラムは次のような構造になっています。

やりたいことを選択するこのメニューファイルがあります (これはほんの一部です):

case 1

plot_handles = createPlot(plot_handles);

case 2

changeWidth(plot_handles);       

ケース 1 では、図にインデックスを付けて、プロットされる関数を記述し、メニューに戻ることができます。

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

メニューに戻ると、ケース 2 に入ります。ここでは、どの図を編集するかを尋ねられると考えています。選択すると、図の線幅を編集できるはずです。

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

問題は、フィギュア ID が IF ループで正しいかどうかを確認する方法がわからないことです。他の場所では、エラーメッセージを書き出す必要があります。

助けていただければ幸いです。

4

1 に答える 1