arrays - Downsampling, or equalizing vector lengths in matlab -



arrays - Downsampling, or equalizing vector lengths in matlab -

i'm having of basic problem yet can't seem solve it. have 2 big pieces of data. have matrix 48554 x 1 , and matrix b 160272 x 1. want "downsample" matrix b of same length matrix a. moreover, want function can pretty much big m x 1 , n x 1 matrices (so works more specific example). tried using resample function so:

resample(b,length(a),length(b))

however i'm getting error indicating filter length large. next tried using loop extract every ith element matrix b , save new matrix, not working out nicely since vector lengths aren't divisible integer. have other (hopefully simple) ways accomplish this?

you seek using interp1 function. know down-sampling isn't interpolating per se. here's example:

x1 = [0:0.1:pi];%vector length 32 x2 = [0:0.01:pi];% vector length 315 y1 = sin(x1); y2 = sin(x2); %down sample y2 same length y1 y3 = interp1(x2,y2,x1);%y3 length 32 figure(1) plot(x2,y2); hold on plot(x1,y1,'k^'); plot(x1,y3,'rs'); % in general utilize method down-sample (or up-sample) vector: % resampled = interp1(current_grid,current_vector,desired_grid); % desired_grid monotonically increasing vector of desired length % example: x5 = [0.0:0.001:1-0.001]; y5 = sin(x); % if want downwards sample y5 100 info points instead of 1000: y6 = interp1([1:length(y5)],y5,1:1:100); % y6 100 info point long. notice didn't utilize other info except y6, length of y6 , desired length.

arrays matlab vector sampling resampling

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -