【发布时间】:2016-01-11 08:13:32
【问题描述】:
我正在使用用于 matlab gui 的 GUIDE。 为通过 GPIB 与 keithley 电流测量设备通信而构建的 gui。 当使用切换按钮进行当前测量 while 循环时,我在每次迭代的 while 循环内使用 pause() 函数,并在 y 数组读取结果上使用 ytranspose。
function Measure_Callback(hObject, eventdata, handles)
global GPIB1
global filename
global timeStep
disp('Measurement in progress \n stopwatch starts!');
tic
x=0;
n=0;
while get(hObject,'Value')
fprintf(GPIB1, 'printnumber(smua.measure.i(smua.nvbuffer1))');
fprintf(GPIB1, 'printbuffer(1,1,nvbuffer1)');
A = fscanf(GPIB1);
if length(A)<20
x = x+1;
n = n+1;
t(n) = toc ;
y(x) = str2double(A);
plot(t,y,'-bo',...
'LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor',[.49 1 .63],...
'MarkerSize',10);
grid on
hold on
end
title('Current vs Time','FontSize', 15)
xlabel('Time [s]','FontSize', 15)
ylabel('Current [A]','FontSize', 15)
a = timeStep;
pause(a)
end
disp('Measurement terminated');
disp('Elapsed time: ');
elapsedtime = toc;
elapsedtime_string = num2str(elapsedtime);
disp(elapsedtime_string);
ytrans = transpose(y);
csvwrite(filename,ytrans);
fprintf(GPIB1, 'smua.source.output = smua.OUTPUT_OFF');
对于暂停功能,我遇到了错误: ??在评估 uicontrol 回调时使用 ==> 暂停错误
对于 transpose(y) 函数,我也遇到了错误: 未定义的 y。
无法理解为什么会出现这些错误,并且可以使用一些帮助。 谢谢!
【问题讨论】:
-
StackOverflow 上的问题通常应包含Minimal, Complete, and Verifiable example。您发布的代码不完整,也无法验证。请edit您的问题,以确保您问题中的代码是Minimal(仅是重现所需的代码)、Complete(重现所需的所有代码)和可验证(我们应该能够仅使用您问题中的代码来重现问题,仅此而已)。
-
在询问错误和警告时,最好发布整个消息和堆栈跟踪而不是解释。
标签: matlab