0
votes

I am using the GUIDE for matlab gui. The gui built in order to communicate with keithley current measurement device through GPIB. When using a toggle button for Current measurement while loop, i am using a pause() function inside the while loop for each iteration and a ytranspose on the y array reading results.

    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');  

For the pause function i'm geting error: ?? Error using ==> pause Error while evaluating uicontrol Callback

For the transpose(y) function i'm also getting a error: its undefined y.

Cant understand why are those errors and could use some help. Thank you!

1
Questions on StackOverflow generally should contain a Minimal, Complete, and Verifiable example. The code that you have posted is not complete nor verifiable. Please edit your question to ensure that the code in your question is Minimal (only the code necessary to reproduce), Complete (all of the code necessary to reproduce) and Verifiable (we should be able to reproduce the issue using only the code in your question, nothing less and nothing more). - excaza
When asking about errors and warnings it's also preferable that you post the entire message and stack trace rather than your paraphrasing. - excaza

1 Answers

0
votes

First off, as people say, post the errors and the code. Do you know if length(A) is smaller than 20 in the first time you run the loop? Because if not, A is not defined and you can't transpose something that is not there. Initialize A before the loop to something and see if the error persists (or print out length(A) to make sure the loop gets entered the first run).

As for the pause error, make sure pause is an int or double, not a string. If you get your global timeStep from the GUI field, it is probably a string and you need to covert it to double first.