当前位置: 动力学知识库 > 问答 > 编程问答 >

Matlab: conv(u,v) but that sums 'u' and 'v'?

问题描述:

Is there any function in Matlab like conv(u,v) but that sums up 'u(x)' and 'v(x)' instead of multiplying them?

Imagine:

u(x) = 66*(x-6)

v(x) = 6*(x-9)

Applying this "wanted function"...

sum = wantedfunction(u,v)

So,

sum(x) = 66*(x-6) + 6*(x-9)

Any ideas?

网友答案:

I believe you can do what you are asking for using anonymous functions:

u = @( x ) ( 66 * (x - 6) );
v = @( x ) (  6 * (x - 9) );
w = @( x ) ( u(x) + v(x) );

This makes w the "sum" function you wanted - if I understood your question correctly.

Example: after I keyed in the above, I found

w(1:5)

Gave

 -378 -306 -234 -162  -90

It's possible I completely missed the point of your question - if so, please leave a comment.

网友答案:

If by "conv" function you mean convolution then the equivalent of that for your case is simply adding two functions you want and then multiply them by delta(your desired spacing on x axis) and then sum over that, gives your function. Still you need to iterate this process by a "for" loop for different delays.

分享给朋友:
您可能感兴趣的文章:
随机阅读: