error in ploting of continuous wave graph form using real time discrete data values
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!