Growing array with fscanf data in matlab


i trying send value arduino matlab , read serial data fscanf() in matlab arduino.

my requirements need able send data @ specified time interval i.e 20 values persecond @ .05 seconds. , need able graph incoming data , able save later use. know length of array before start have read , seen can used speed process.

the problem having each iteration of loop becomes successively longer throws time behavior off more. believe due growing array inside of loop have.

code: [select]
x = linspace(0,time1,tosd)';
x1 = amp*sin(x*(2*pi/20)) + offset;
y = zeros(length(x),1);
i = 1;
figure(1);
hold on;
title('pressure data');
xlabel('data number');
ylabel('analog voltage (0-1023)');
t1 = zeros(length(x),1);
figure(2);
hold on;
title('time execute task');
xlabel('iteration number');
ylabel('time taken');
while (i<=length(x))
    t2 = tic;
    t = tic;
    fprintf(handles.ultram,(['<p' num2str(x1(i)) '>']));
    disp((['<p' num2str(x1(i)) '>']));
    y(i) = fscanf(handles.ultram,'%i');
    figure(1);
    hold on;
    plot(i, y(i), 'b*');
    plot(i, pressure, 'b*');
    drawnow;
    hold off;
 while toc(t) < 0.05
     continue
 end
    t1 = toc(t2);
    figure(2);
    hold on;
    plot(i,t1,'b*');
    drawnow;
    hold off;
    = + 1;
end


the last tic toc finction used can graphically see slowdown time.

thank in advance help



Arduino Forum > Using Arduino > Interfacing w/ Software on the Computer > Growing array with fscanf data in matlab


arduino

Comments

Popular posts from this blog

Valutazione Template - Joomla! Forum - community, help and support

SD Datastring Convention

First use of Arduino Uno : avrdude error on Blink uploading