error in ploting of continuous wave graph form using real time discrete data values

1 visualización (últimos 30 días)
hello experts, i am trying to get real time values from serial port, which is connected to microcontroller... now with the help of MATLAB i am able to get continuous discrete data values in the range 130 to 190.which i have to plot continuous wave form in the range -30 to +30 range ,instead of discrete wave form..... i have posted my code bellow..... help me with the solution or advice please..
before going through the code, data = fscanf(s); returns example ''value1=164v''
close all;
clear all;
clc
s = serial('COM5')
fopen(s);
time=0; delay = 0.005; value=0; delta=0.02; graph1 = plot(time,value, 'g-');
hold on;
while ishandle(graph1)
data = fscanf(s);
[token, remain] = strtok(data);
if strcmp(token, 'VALUE1')
temp1 = strrep(data, 'VALUE1', '');
temp2 = strrep(temp1, '=', '');
value = strrep(temp2, 'V', '')
value = str2double(value);
value=value-160;
time=time+delta;
end
plot(time,value,'g-','LineWidth',30,'Color',[0 1 0]);
axis([0 time -20 20]);
drawnow
hold on
time=time+delta;
pause(delay);
end

Respuestas (0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by