I need to plot a graph for that I have two files velocity and time. But I have to plot the graph for certain interval of time, so can you help me how should I get the corresponding velocity points as both the files are in vector form.
Thanks

 採用された回答

Guillaume
Guillaume 2016 年 2 月 24 日

0 投票

See Using logicals in array indexing. In your case it's going to be something like:
%time: vector of time
%velocity: vector of velocity
intime = time >= starttime & time <= endtime
plot(time(intime), velocity(intime))

2 件のコメント

Ryaan Semwal
Ryaan Semwal 2016 年 2 月 24 日
編集済み: Stephen23 2016 年 2 月 24 日
Hi,
Thanks for your quick reply. I am new to matlab so I am attaching my script in this comment as I am getting error. I will be thankful to you if you can help me figure out my mistake
Thanks
names = dir('*.smat.mat');
names = {names.name};
for i = 1:length(names)
S = load(names{i});
time_data=S.timezones;
% isfield(S,'timeClean')
whole_time=S.timeClean;
% A=sort(velocity_data);
% % timepoints=whole_time(whole_time(:,1) >= time_data(1,1) & whole_time(:,1) < time_data(2,1));
velocity_data=S.VelClean;
% velocity_index=(velocity_data>time_data(1,1)) & (velocity_data<time_data(1,1))
intime=time>time_data(1,1)& time<=time_data(2,1);
plot(whole_time(intime),velocity_data(intime))
% end
end
Ryaan Semwal
Ryaan Semwal 2016 年 2 月 24 日
hi, Figured out the mistake. Thanks a lot for your help.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by