Click button uifigure callback function

9 ビュー (過去 30 日間)
Julien Maxime
Julien Maxime 2022 年 10 月 24 日
コメント済み: Julien Maxime 2022 年 10 月 24 日
Hello,
I am trying to set a function in which I get back coordinates from a graph in my uifigure (uiaxes ax4) and plot another based on these coordinates (uiaxes ax5). The first part works very well as if I put stopper in the function I can see that coordinates are well retrieved and stored.
Still I have the following error when it passes through the squeeze command. "data" is a 3D matrix that I put as an input to my function but when I stop the function in the middle it does not seem to be imported in the workspace. What command am I missing ?
Thanks you !
" Not enough input arguments.
Error in SAGUIimagesc/ImageClickCallback (line 265)
Yaxis = squeeze(data(XcR,YcR,:));
Error while evaluating Image ButtonDownFcn."
A = imagesc(ax4, data(:,:,2));
set(A,'ButtonDownFcn',@ImageClickCallback);
function ImageClickCallback (objectHandle, eventData, ax5, data)
axesHandle = get(objectHandle,'Parent');
Coord = get(axesHandle,'CurrentPoint');
Xc = Coord(1,1);
Yc = Coord(1,2);
XcR = round(Xc);
YcR = round(Yc);
Xaxis = linspace(1,s(3),s(3));
Yaxis = squeeze(data(XcR,YcR,:));
plot(ax5, Xaxis, Yaxis);
end

採用された回答

Jan
Jan 2022 年 10 月 24 日
This looks strange. I do not see the reason for the error. Is this really the complete error message?
Use the debugger to check, what's going on. Type this in the command window:
dbstop if error
Then run the code again until it stops. Now check the values of the used variables:
squeeze(data(XcR,YcR,:))
XcR
YcR
size(data(XcR,YcR,:))
which data
which squeeze
  2 件のコメント
Julien Maxime
Julien Maxime 2022 年 10 月 24 日
Ok so I got the error in orange:
"Warning: Error occurred while executing the listener callback for event ForceStream defined for class matlab.internal.editor.StreamOutputsSignal:
Error using matlab.internal.editor.StreamOutputsSignal.forceStream
Unexpected type in OutputPackager.packageOneOutput: UncaughtError.
Dump of evalStruct:
type: 'UncaughtError'
payload: [1×1 struct]
stack: [8×1 struct]
Payload of evalStruct:
UncaughtErrorEvent: [1×1 struct]
UncaughtErrorEvent_RequestIdAdapter: [1×1 struct]
exception: [1×1 struct]
isRecursionLimitError: 0
Error in SAGUIimagesc/ImageClickCallback (line 265)
Yaxis = squeeze(data(XcR,YcR,:));"
For the second part:
XcR = 8
YcR = 6
The issue comes when we use data:
"K>> data(XcR,YcR,:)
Not enough input arguments."
I don't know why but data is not present into the workspace. It seems to imported despire puting it in input of the function. Yet if nothing refered to data i should have another type of error. When i type "which data", it respond me "data is a variable"
Julien Maxime
Julien Maxime 2022 年 10 月 24 日
Ok I solved it. I don't really know why but actually it works if I do not import "ax5" and "data" elements. I guess they are already imported through "objectHandles".
Hoping it helps somebody one day !
Still thank you for your help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by