MATLAB: Dimensions don’t agree – how to fix

dimensionsdimensions don't agreegraph plottingmatrix dimensions

Hi, I tried to run the following script but couldn't get it to run because the dimensions don't agree. Any pointers on how to fix this guys? Script below
function PL = ppressure(t)
vol_tid = 0.41 ;
Pm = 760;
R = 1;
w = 2*pi*(0.2);
E = 70;
t=[0:2.5:17.5]
PL = Pm -(R*w)*(2*pi*t)*(0.5*vol_tid)*sin(w*t) - E*((2.5 - (0.5 * vol_tid)) * cos(w*t))
plot(t,PL),
title('y-ppressure')

Best Answer

When in doubt, vectorise !
This works:
PL = Pm -(R*w)*(2*pi*t).*(0.5*vol_tid).*sin(w*t) - E*((2.5 - (0.5 * vol_tid)) * cos(w*t));