[ Close ] Username Password Forgotten your password? @import url(http://www.google.com/cse/api/branding.css); Custom Search
 MATLAB Projects Projects Q A, Guidance for your projects » Projects Forum » MATLAB Projects Topic: Matlab - Summation two variables  Oldest Post First Newest Post First Found this useful? Give a +1 Add to Facebook: Author Message skumar Senior Member Joined: 19-Oct-2008 Location: United Kingdom Online Status: Offline Posts: 252 Topic: Matlab - Summation two variables    Posted: 06-Feb-2018 at 7:08pm I'm fairly new to Matlab programming and am having difficulty expressing this equation on Matlab: g(j)= ∑ (y(n)*x(n-j)) where the sum is from n = 8 to 10 for example. The end result I want is a discrete function like: g(j) = y(8)*x(8-j) + y(9)*x(9-j) + y(10)*x(10-j) which I'll ultimately evaluate with a for loop at say j = 6 and 7. x(n) and y(n) are defined from n=0,...,1000 by the way. Anybody have any tips on how to accomplish this. This may be simple, but for some reason is giving me problems. IP Logged siva Newbie Joined: 19-Oct-2008 Online Status: Offline Posts: 0 Posted: 06-Feb-2018 at 7:10pm Kumar, If I got you wrong, please let me know. Being new to MATLAB, you may not know some critical points. If you're not working with Symbolic concept, MATLAB works with only numbers (i.e., matrices). So, I think choosing j=6,7 does not make sense. I'm ok with the creation of the function g, I think you're trying to convolve these two signals but why do you want it to take the values 6 and 7 at the same time? Let's say there is no mistake. The requested form is like shown below; code: 1. x=1:2:2000;% linspace command could be used like x=linspace(0,2000,1000); 2. y=0:2:1999;% linspace command could be used like y=linspace(1,1999,1000); 3. g=[]; 4. sum6=0; 5. sum7=0; 6. j=6;     7. for i=8:10 8.    g(j)=y(i)*x(i-j); 9.    sum6=sum6+g(j); 10. end 11. j=7; 12. for i=8:10 13.    g(j)=y(i)*x(i-j); 14.    sum7=sum7+g(j); 15. end 16. fprintf('g(6) is equal to %d\n', sum6) 17. fprintf('g(7) is equal to %d\n', sum7) This code may be reorganized but I prepared the code like this because you need to learn MATLAB step by step. If you need to ask sth, please don't hesitate. IP Logged PrashanthS Newbie Joined: 21-Sep-2008 Online Status: Offline Posts: 0 Posted: 06-Feb-2018 at 7:11pm If you're interested in learning how to actually code this, the above is a good suggestion. But if you just want the result, try the conv() function (or any of the assortment of fir() type functions)  IP Logged  Free Programming Courses in JAVA, .Net and PHP (Register Now!)

Java Free Online Course

.Net Free Online Course

PHP Free Online Course Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

This page was generated in 0.031 seconds.