Problem with vectors dimensions

hello every one! I tried to solve this Equation
and i should get this result
and I have already the data and I used this matlab code
RN = [8 -7.72 -3.4616 5.6457 -1.9739];
TN = [-8 7.72 -0.5384 -1.7857];
rN=conv(RN,RN);
tN=conv(TN,TN);
E=[0 -1];
S=conv(E,tN);
R=rN+tN+S;
but I got this error
%
Error using +
Matrix dimensions must agree.
Error in test (line 15)
R=rN+tN+S;
if you have advise for me to solve this Equation please tell me thank you

 Accepted Answer

Walter Roberson
Walter Roberson on 9 Jan 2018
Edited: Walter Roberson on 9 Jan 2018
RN and TN are undefined. You define RD and TD.
You appear to be conv'ing vectors that have different lengths: there is no obvious reason why it would be reasonable to add the results.
Also, you should consider looking at the conv() options 'same' and 'valid'
... though I cannot tell from the equation why you are using conv() at all.

6 Comments

Your revised version defines RN and TN, but they still have different lengths, so it is not clear why it would be expected you could add their convolutions.
Walter Roberson
Walter Roberson on 9 Jan 2018
Edited: Walter Roberson on 9 Jan 2018
Are R_N and T_N intended to represent discrete filters? If so then you have missed the point that the filters are to be applied to u. If you were trying to calculate an overall filter then you could zero pad the shorter arrays before adding (but be sure you zero pad on the correct side -- and note that for filters it would be more common to use filter() instead of conv(), with the two differing in whether the coefficients are to be used left to right or right to left.)
Thank you for notify me I had a mistake with RT and RN and corrected it I used conv function because i work with vectors and if you have another Suggestion tell me please i should to get this result
In fact, I am trying to calculate some algorithms for control and have nothing to do with filters
To illustrate more these equations are RN TN
Easiest to work with symbolic
syms K u
RN = [8 -7.72 -3.4616 5.6457 -1.9739];
TN = [-8 7.72 -0.5384 -1.7857];
F = K * (poly2sym(RN,u).^2 + (1-u.^2).*poly2sym(TN,u).^2)
vpa(expand(F))
Numerically:
RN = [8 -7.72 -3.4616 5.6457 -1.9739];
TN = [-8 7.72 -0.5384 -1.7857];
RN2 = conv(RN,RN);
TN2 = conv(TN,TN);
E = [-1 0 1];
S = conv(E,TN2);
temp = RN2 + S; %they happen to be the same length
result = K * temp(find(temp,1,'first'):end); %index to remove leading 0

Sign in to comment.

More Answers (0)

Products

Tags

Community Treasure Hunt

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

Start Hunting!