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

15 Ansichten (letzte 30 Tage)
Rion Iguchi
Rion Iguchi am 12 Jan. 2021
Kommentiert: Rion Iguchi am 14 Jan. 2021
スクリプトでplot関数を実行しても、グラフの線が表示されません(以下画像を参照)。しかしコマンドウィンドウで同じ関数を実行すると問題なく表示されます。
リアルタイムにデータをプロットしたいので、スクリプトでの実行が必要です。どのように解決することができますか。
  2 Kommentare
Shunichi Kusano
Shunichi Kusano am 14 Jan. 2021
書かれている内容だけですと原因がわからないので、コードを載せていただくことは可能でしょうか。スクリプトの方でplotの実行までに何らかの不具合が起こっているのではないかと思うのですが…。
Rion Iguchi
Rion Iguchi am 14 Jan. 2021
以下、コードです。
ループを途中で止めてコマンドから引数の同じ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

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu グラフィックス パフォーマンス finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2019a

Community Treasure Hunt

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

Start Hunting!