comparison of vectors and reducing size

2 vues (au cours des 30 derniers jours)
Tahir Afareen
Tahir Afareen le 6 Oct 2019
Commenté : Tahir Afareen le 6 Oct 2019
Greetings,
I have three vectors A , B and C of sizes 299×1 , 499×1 and 1609×1 respectively. i need code to simply reduce the size of the two large vectors (in this case B and C) to the size of the smallest vector (in this case A). how do i do that?

Réponse acceptée

meghannmarie
meghannmarie le 6 Oct 2019
If you want to just keep the first 299 elements:
sz = min([length(A),length(B),length(C)]);
A = A(1:sz);
B = B(1:sz);
C = C(1:sz);
  1 commentaire
Tahir Afareen
Tahir Afareen le 6 Oct 2019
Thank you very much meghannmarie.
problem solved.

Connectez-vous pour commenter.

Plus de réponses (1)

Ajay Kumar
Ajay Kumar le 6 Oct 2019
doc interp1
use linear interpolation, to upsample or downsample the vector to any length required
A = rand(299,1);
B = rand(499,1);
v = (1:numel(B))';
vr = (linspace(min(v), max(v), length(A)))';
newB = interp1(v, B, vr);
Hope this helps :)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by