Surf plot on GUI interface

14 ビュー (過去 30 日間)
Julien Maxime
Julien Maxime 2022 年 10 月 4 日
コメント済み: Simon Chan 2022 年 10 月 4 日
Hello,
For my project, I would like to integrate a surf plot onto a GUI interface with a slider that update the plot inside the interface.
I tested the surf plot apart and it works fined but when i try to take the same structure as "Heatmap version" of the code that worked fine i got the error:
"Error using surf
Z must be a matrix, not a scalar or vector.
Error in TimeLapseInterpolatedMap (line 72)
heatObj = surf(uip,Vq);"
Of course, I understood that putting "iup" in the first argument of surf function doesn't work but then I don't know how to integrate it with my GUI.
Con you help me ?
Thank you !
% HEATMAP VERSION (WORKING)
data = M;
fig = uifigure();
uip = uipanel(fig,'Position', [20 100 500 300]);
heatObj = heatmap(uip, data(:,:,1),'Colormap', hsv,'CellLabelColor', 'none','ColorLimits', [-500 400]);
heatObj.Title = 'Electrode Fluorescence Heatmap - Frame 1';
n = size(data,3);
uis = uislider(fig,'Position',[50 50 450 3],...
'Value',1, ...
'Limits', [1,n], ...
'MajorTicks', 0:200:n, ...
'MinorTicks', []);
%valueChangedFcn for actualisation only when cursor is dropped
uis.ValueChangingFcn = {@sliderChangingFcn, data, heatObj};
function sliderChangingFcn(~,event,data,heatObj)
% Update heatmap and title with new selection of data
value = round(event.Value);
heatObj.ColorData = data(:,:,value);
heatObj.Title = sprintf('Electrode Fluorescence Heatmap - Frame #%d',value);
end
% SURF VERSION (NOT WORKING)
data = M;
fig = uifigure();
uip = uipanel(fig,'Position', [20 100 500 300]);
[Xq,Yq] = meshgrid(1:0.1:12);
Vq = interp2(data(:,:,1),Xq, Yq, 'cubic');
heatObj = surf(uip, Vq);
n = size(data,3);
uis = uislider(fig,'Position',[50 50 450 3],...
'Value',1, ...
'Limits', [1,n], ...
'MajorTicks', 0:200:n, ...
'MinorTicks', []);
%valueChangedFcn for actualisation only when cursor is dropped
uis.ValueChangingFcn = {@sliderChangingFcn, data, heatObj};
function sliderChangingFcn(~,event,data,heatObj)
% Update heatmap and title with new selection of data
value = round(event.Value);
heatObj.ColorData = data(:,:,value);
heatObj.Title = sprintf('Electrode Fluorescence Heatmap - Frame #%d',value);
end

回答 (1 件)

Simon Chan
Simon Chan 2022 年 10 月 4 日
Create an uiaxes inside the uipanel or you can simply use uiaxes instead of uipanel inside the uifigure.
  6 件のコメント
Simon Chan
Simon Chan 2022 年 10 月 4 日
Are you looking for function view?
I don't have too much experience in 3D view and hence may not understand your needs, Sorry.

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by