compare two vectors plot

5 次查看(过去 30 天)
Hi,I have 2 vectors of length 1024, I want to take 100 samples equally spaced from each to make a comparison plot?

采纳的回答

the cyclist
the cyclist 2016-5-29
编辑:the cyclist 2016-5-29

Of course, it is not possible to do this perfectly evenly spaced, and span the entire vector, so you have to make some compromise somewhere.

Here is one possibility. It will generalize to other cases:

% Some made-up data
N = 1024;
a = sort(rand(1,N));
b = sort(rand(1,N));
% How much to sample
N_sample = 100;
% Create an (almost) uniform sample
sampleIdx = round(linspace(1,N,N_sample));
a_sample = a(sampleIdx);
b_sample = b(sampleIdx);
% Plot
figure
plot(a_sample,b_sample)

Here is the result ...

  1 个评论
yousef Yousef
yousef Yousef 2016-5-29
Perfect ,Thanks,just I notice, the comparison should be done as:
t=1:100;
plot(t,a_sample,t,b_sample)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Geometry and Mesh 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by