Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,154,753 members, 7,824,162 topics. Date: Saturday, 11 May 2024 at 01:35 AM

Matlab Help Needed,please - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Matlab Help Needed,please (2198 Views)

Matlab: A Program For Mathematicians? / MATLAB: The Language Of Technical Computing (2) (3) (4)

(1) (Reply) (Go Down)

Matlab Help Needed,please by dustydee: 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: 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:

function sig=nl(f,a,p,fs,dur)
% Default parameters.
if (nargin == 0)
    f=100; a=2.0; p=50; fs=8000; dur=0.01;
end
w = 2*pi*f;
t=0:1/fs:dur;
sig=a*cos(p+w*t);
Re: Matlab Help Needed,please by dustydee: 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: 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);
t=0:1/fs:dur;
arg=j*2*pi*f'*t;
sig_out=real(x*exp(arg));
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: 7:15am On Oct 27, 2011
Yea thanks alot. That link was very helpful too,never knew there was something like that.

(1) (Reply)

VOTE: Seun Add Direct Message To Nairaland / Universal Files And Folders Encryption (PGP) - Good For You / C Or C++, Which Is Best For Arduino Programming?

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 11
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.