我的代码中有一个子例程,我在其中创建了一个 GUI 供用户选择一种分析类型:
%% Gives user the choice of replacement method
figure('Units','Normalized','Color','w','Position',[.3 .6 .4 .15],...
'NumberTitle','off','Name','Analysis choice','MenuBar','none');
uicontrol('Style','text','Units','Normalized',...
'Position',[.1 .7 .8 .2],'BackgroundColor','w','String','What replacement method do you want to use?');
uicontrol('Style','pushbutton','Units','Normalized',...
'Position',[.05 .3 .3 .3],'String','Cubic interpolation 24 points',...
'CallBack','cubic_choice'); % cubic_choice.m rotine must be on current folder
uicontrol('Style','pushbutton','Units','Normalized',...
'Position',[.4 .3 .3 .3],'String','Last good data value',...
'CallBack','lgv_choice'); % lgv_choice.m rotine must be on current folder
uicontrol('Style','pushbutton','Units','Normalized',...
'Position',[.75 .3 .2 .3],'String','Linear interpolation',...
'CallBack','li_choice'); % li_choice.m rotine must be on current folder
uiwait;
close;
在代码中,我有一个 if 循环来分析用户做出的选择:
if strcmp(inp,'cubic') ...
问题是,当我按下“三次插值 24 点”按钮时,回调函数没有给我inp
变量,即它没有出现在工作区上。回调函数是这样的:
%% Callback script for replacement method
% Cubic interpolation with 24 points method
function [inp] = cubic_choice
inp = 'cubic';
uiresume(gcbf); % resumes the button call
我知道我可能必须使用 setappdata 和 getappdata,因为我已经在其他线程中阅读过它,但我无法让它工作。
谁能帮我?
提前致谢。
亲切的问候,佩德罗·桑切斯