Programming Problem on code

4 ビュー (過去 30 日間)
Bilal Sadiq
Bilal Sadiq 2020 年 10 月 23 日
コメント済み: Fangjun Jiang 2020 年 10 月 23 日
Hi all ,,
I shall be very grateful to you if you answer my query ,,,My problem is i want to genereate the following graph
t1=[0 0.1 0.3 0.4 0.5 0.7 0.8];
y=[-10 10 15 10 8 -5 0];
Now what i want is : I want to repeat this graph upto t=10 sec (i have time vector t=0:0.01:10 and i want to plot the above y axis values till time t=10)
hope i have put my query right,waiting for some positive response
with kind regards
Bilal
  4 件のコメント
Bilal Sadiq
Bilal Sadiq 2020 年 10 月 23 日
See what i have tried to to do but in vain
t=0:0.1:10;
% t_x_ankle=[0 0.1 0.2 0.3 0.4 0.5 0.6...
% 0.7 0.8 0.9 1.0 1.1 1.2 1.3...
% 1.4 0.1 0.2 0.3 0.4 0.5 0.6...
% 0 0.1 0.2 0.3 0.4 0.5 0.6...
% 0 0.1 0.2 0.3 0.4 0.5 0.6];
y_ankle=[-10 10 15 10 8 -5 0];
y=zeros(1,length(t));
count=1;
for i=1:length(t)
y(i)=y_ankle(count)
count=count+1;
if count>7
count=1;
end
end
plot(t,Y,'bo')
Please help me
Fangjun Jiang
Fangjun Jiang 2020 年 10 月 23 日
In the simpliest case, would this be what you want?
y=[-10 10 15 10 8 -5 0];
t1=0:0.1:0.6;
t=0:0.1:10.4;
yy=repmat(y,1,15);
plot(t,yy)

サインインしてコメントする。

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2020 年 10 月 23 日
t1 doesn't contain t=0.2 and t=0.6. Not sure if it is correct or there is a typo.
You can do repmat(y,1,10) or as many times as you want to match t=0:0.01:10
  2 件のコメント
Bilal Sadiq
Bilal Sadiq 2020 年 10 月 23 日
Please see the figure attached ,this is what i want to plot for a time vector of t=0:0.01:10
Fangjun Jiang
Fangjun Jiang 2020 年 10 月 23 日
%% Original data
t1=[0 0.1 0.3 0.4 0.5 0.7 0.8];
y=[-10 10 15 10 8 -5 0];
%% interpolate for more data points
t2=0:0.01:0.8;
y2=interp1(t1,y,t2);

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by