필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
Rakesh
Rakesh 2014년 5월 14일
편집: Rakesh 2014년 5월 14일
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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by