Matlab Help Needed,please - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Matlab Help Needed,please (2270 Views)
| Matlab Help Needed,please by dustydee(op): 11:43pm On Oct 25, 2011 |
I am new to matlab and have been trying to do a loop for a program but keep getting errors some please help on how to go about it. here's the problem: sig=sumcos(f,A,P,fs,dur); let fk = kf0, Ak = 4/(k*pi), Pk = pi/2 for k = 1,3,5 . . . fk = 0, Ak = 0 , Pk = 0 k = 0,2,4,, 4 Use your sumcos function with f0 = 25Hz, fs = 8000, dur =1/f0 sec and N= 5, 10,15, 20 and 25 to plot the synthesized periodic discrete waveform. Use the hold on command to show all signals together. Note Matlab index starts from 1,2,3 , the code I am supposed to modify is: function sig=sumcos(f,a,p,fs,dur) if (nargin == 0) f=100; a=2.0; p=50; fs=8000; dur=0.01; end num=length(f); x=a.*exp(j*p); t=0:1/fs:dur; arg=j*2*pi*f'*t; sig=real(x*exp(arg)) thanks guys |
| Re: Matlab Help Needed,please by dustydee(op): 10:07am On Oct 26, 2011 |
Morning guys, still expecting a reply. Thanks |
| Re: Matlab Help Needed,please by ektbear: 11:05am On Oct 26, 2011 |
See here: http://pastebin.com/SjpRhP4q I'm also not sure why that sumcos() function is so hideous. This is clearer and more concise:
|
| Re: Matlab Help Needed,please by dustydee(op): 3:54pm On Oct 26, 2011 |
Thanks man, it is used to call the function from matlab. It can be anything. Just a name. I can type in sumcos in matlab and fill in the arguments. Have a crude solution though. looking to refine it |
| Re: Matlab Help Needed,please by dustydee(op): 6:02pm On Oct 26, 2011 |
Also I tried the code and it ran just that it does not retain the 5 plots together. then the formula for sig was not used. x=a.*exp(j*p); |
| Re: Matlab Help Needed,please by ektbear: 2:05am On Oct 27, 2011 |
Err I think i've given you pretty much everything you need to solve the problem at this point. Just tweak what I linked to to serve your purposes |
| Re: Matlab Help Needed,please by dustydee(op): 7:15am On Oct 27, 2011 |
Yea thanks alot. That link was very helpful too,never knew there was something like that. |
Matlab: A Program For Mathematicians? • MATLAB: The Language Of Technical Computing • 2 • 3 • 4
Anatomy Of A Contract(part 2) Invitation To Treat And Offer Distinguished • Please Programmers In The House,what Are The Benefits Of Programming • Creating Best Programming Tutorials For Africans - Need Feedback