Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
Rakesh
Rakesh le 14 Mai 2014
Modifié(e) : Rakesh le 14 Mai 2014
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

Réponses (0)

Catégories

En savoir plus sur Graphics Performance dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by