フィルターのクリア

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 Center および File ExchangeGraphics Performance についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by