Click button uifigure callback function
4 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop uifigure-Based Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!