How to use message box?
古いコメントを表示
I have some code that works out the y value of the first point on my graph where x>6. This is the 'failure' point.
figure
plot(x,y), hold all
failure=find(x>6,1);
I want to the display whatever this y_value is in a message box on the figure. Any ideas?
回答 (2 件)
Adam
2015 年 3 月 6 日
doc msgbox
has numerous examples. It is very simple to use, but if you have any questions after looking at that page then feel free to ask those.
Image Analyst
2015 年 3 月 6 日
Try this
% Find first element where x exceeds 6
index = find(x>6, 1, 'first');
% Get the x and y values for that index
x6 = x(index);
y6 = y(index);
% Make up a message to put on the plot:
message = sprintf('Failed at (x,y) = (%f, %f)', x6, y6);
% Place the message in a text box near the x,y point:
text(x6, y6, message, 'FontSize', 14);
1 件のコメント
Image Analyst
2015 年 3 月 6 日
If you want a popup message box instead of a text label sitting on your plot axes, use
uiwait(helpdlg(message));
カテゴリ
ヘルプ センター および File Exchange で App Building についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!