スクリプトのコードを​実行した際にplot​の線が表示されない

조회 수: 8 (최근 30일)
Rion Iguchi
Rion Iguchi 2021년 1월 12일
댓글: Rion Iguchi 2021년 1월 14일
スクリプトでplot関数を実行しても、グラフの線が表示されません(以下画像を参照)。しかしコマンドウィンドウで同じ関数を実行すると問題なく表示されます。
リアルタイムにデータをプロットしたいので、スクリプトでの実行が必要です。どのように解決することができますか。
  댓글 수: 2
Shunichi Kusano
Shunichi Kusano 2021년 1월 14일
書かれている内容だけですと原因がわからないので、コードを載せていただくことは可能でしょうか。スクリプトの方でplotの実行までに何らかの不具合が起こっているのではないかと思うのですが…。
Rion Iguchi
Rion Iguchi 2021년 1월 14일
以下、コードです。
ループを途中で止めてコマンドから引数の同じplot関数を実行すると表示されました。
連続でplot関数を実行させるのが問題なのでしょうか。。
よろしくお願いいたします。
-----------------------------------------------------------------------------------------------------------------------------------------
clear;
close all;
s = serial("COM7", "Baudrate", 460800, "Terminator", "CR", "FlowControl", "software");
fopen(s);
count = 1;
max_count = 50;
count_s = 1:max_count;
data_x = zeros([1,max_count]);
data_y = zeros([1,max_count]);
data_z = zeros([1,max_count]);
time = 0.05;
while(1)
x = str2double(fgetl(s));
y = str2double(fgetl(s));
z = str2double(fgetl(s));
if(count > max_count)
count_s = horzcat(count_s(2:end),count);
data_x = horzcat(data_x(2:end),x);
data_y = horzcat(data_y(2:end),y);
data_z = horzcat(data_z(2:end),z);
plot(count_s, data_x, count_s, data_y, count_s, data_z);
else
data_x(count) = x;
data_y(count) = y;
data_z(count) = z;
plot(count_s(1:count), data_x(1:count), count_s(1:count), data_y(1:count), count_s(1:count), data_z(1:count));
end
count = count + 1;
xlim([count(1),count(1)+max_count]);
ylim([-inf,inf]);
drawnow limitrate
%pause(time);
end

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 グラフィックス パフォーマンス에 대해 자세히 알아보기

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!