2016-08-17 14 views
0

私は時間とともに変化する図形をプロットしようとしています(風が通過するときに極の形をプロットすると考えるので、1秒おきに図形をプロットする必要があります)。時間とともに変化する図表

x軸の制限が頻繁に変更されるのを避けるために、私はそれを限界まで修正したい(プロットする前に計算した最大値と最小値)。ここに私のコードのサンプルです:

for i=1:1:numberofrows 
    momentvaluesatinstant = momentvalues(i,:); 
    figure(1) 
    plot(momentvaluesatinstant,momentheader) 
    drawnow 
    title(sprintf('Moment profile along pile at time 0.2%f',time(i)')) 
    xlabel('Moment (kN.m)') 
    xlim([momentvalues(rowminmoment) momentvalues(rowmaxmoment)]) 
    ylabel('Length of pile (m)') 
    delay(1); 
end 

私は私が指定した値に固定されるようにx軸の範囲を指定しておりますが、プロットがプロットされたデータに応じた制限を変更し続けますか?私が紛失しているものはありますか?

+0

[見てみましょう私の答え](http://stackoverflow.com/a/39059154/2627163)よりコンパクトで正確なMATLABのアニメーション化の方法については、 – EBH

答えて

0

は、私はあなたがxlim manualを必要とする理由わからないんだけど、ここにあなたのデータをアニメーション化するために、よりコンパクトで、正しい方法であるxlim manual

0

を追加する必要があり、それを考え出し:

% use 'figure', `plot` and all the constant parts of the figure only once, before the loop. 
figure(1) 
m = plot(momentvalues(1,:),momentheader); % plotting only step 1 
xlim([momentvalues(rowminmoment) momentvalues(rowmaxmoment)]) 
xlabel('Moment (kN.m)') 
ylabel('Length of pile (m)') 

% loop from step 2 ahead 
for k = 2:length(momentvalues) 
    pause(1); % use pause to set the delay between shots 
    % use 'set' to change the x values 
    set(m,'Xdata',momentvalues(k,:));  
    drawnow 
    title(sprintf('Moment profile along pile at time 0.2%f',k)) 
end 
関連する問題