【发布时间】:2021-07-27 08:59:13
【问题描述】:
我正在尝试创建一个可以使用滑块修改多个变量的 GUI。这是我到目前为止的示例:我试图通过对两个滑块求和来改变线性函数的梯度。
我对 octave 和 matlab 的 gui 完全陌生,所以我认为存在一些基本错误。
%%%%%% In file myplot.m %%%%%
function myplot
%% Create initial figure and spiral plot
figure;
axes ('position', [0.1, 0.3, 0.8, 0.6]);
global t;
t = linspace (0, 100, 101)
x = t;
y = t;
plot (x, y);
axis ([-100, 100, -100, 100]);
%% Add ui 'slider' element
hslider = uicontrol ( ...
'style', 'slider', ...
'Units', 'normalized', ...
'position', [0.1, 0.1, 0.8, 0.1], ...
'min', -100, ...
'max', 100, ...
'value', 0, ...
'callback', {@plotstuff} ...
);
%% Add ui 'slider' element
kslider = uicontrol ( ...
'style', 'slider', ...
'Units', 'normalized', ...
'position', [0.1, 0, 0.8, 0.1], ...
'min', -100, ...
'max', 100, ...
'value', 0, ...
'callback', {@plotstuff} ...
);
end
%% Callback function called by slider event
%% Also in file myplot.m (i.e. a subfunction)
function plotstuff (h, k, event)
global t;
n = get (h, 'value');
m = get (k, 'value');
x = t;
y = (n+m) * t ;
plot (x, y);
axis ([-100, 100, -100, 100]);
end
这是我的错误信息:
㎫ >> 错误:运算符 *:不一致的参数(op1 是 0x0,op2 是 1x101) 错误:调用自 octave_test>plotstuff 在第 43 行第 5 列 错误:运算符 *:不一致的参数(op1 是 0x0,op2 是 1x101) 错误:调用自 octave_test>plotstuff 在第 43 行第 5 列
这是图形窗口:
【问题讨论】:
标签: user-interface slider octave