MATLAB Answers

how to resize a given signal?

how to resize a given signal? My input signals are y2=[ 1 9385];yh=[1 37508]; I need to find y2+y5.


What is y5?

Do the signals occupy exactly the same time duration ?


2 Answers

Answer by Image Analyst
on 27 Mar 2013
Edited by Image Analyst
on 27 Mar 2013

You'll probably want to use either interp1() or imresize(). Both are illustrated in the demo below:

y2 = rand(1, 9385);
y5 = rand(1, 37508);
% The easiest method, using imresize().
% Make y2 the same size as y5
y2Larger = imresize(y2, size(y5));
% Now sum them
output = y2Larger + y5;
% Alternative method using interp1
x = linspace(1, length(y5), length(y2));
xi = 1:length(y5);
y2Larger  = interp1(x, y2, xi)
% Now sum them
output = y2Larger + y5;


Answer by Ahmed A. Selman
on 27 Mar 2013

Use reshape


It works for any input matrix (X) with number of elements (m x n). The output is Y with m-rows by n-columns. The size of X and Y must be the same.


Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!