COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Problems with functions

• Email
• Follow

```Hi im having a problem using Matlab, I will be really grateful if someone could help or give me a hint on the error in my code so here it goes:
I have to create a function to plot a sine wave with different parameter as: amplitude(A), phase(theta), fequency(f), sample frequency(fs) and end time(T_end), so I was given this first line:
function [x, t] = single_sine(f, A, theta, T_end, fs);

and then I added the following:
ts = 1./fs;
t = 0:ts:T_end-fs;
x = A.*sin(2.*pi.*f.*t);
plot(t,x)

to me it seems allright but then it gave me this result for both the values of t and x:
'Empty matrix: 1-by-0'

if anyone could give me a hand...cause im totally lost
```
 0

See related articles to this posting

```"ricardo Huertas" <huertas_92@hotmail.com> wrote in message <hqmj3h\$q8o\$1@fred.mathworks.com>...
> Hi im having a problem using Matlab, I will be really grateful if someone could help or give me a hint on the error in my code so here it goes:
> I have to create a function to plot a sine wave with different parameter as: amplitude(A), phase(theta), fequency(f), sample frequency(fs) and end time(T_end), so I was given this first line:
> function [x, t] = single_sine(f, A, theta, T_end, fs);
>
> and then I added the following:
> ts = 1./fs;
> t = 0:ts:T_end-fs;
> x = A.*sin(2.*pi.*f.*t);
> plot(t,x)
>
> to me it seems allright but then it gave me this result for both the values of t and x:
> 'Empty matrix: 1-by-0'
>
> if anyone could give me a hand...cause im totally lost

Hi Ricardo, I don't know what values you are inputting in your function for f,A, etc., but look at the line:

t = 0:ts:T_end-fs;

Wayne
```
 0

1 Replies
192 Views

Similar Articles

12/7/2013 1:48:26 AM
[PageSpeed]

Similar Artilces:

functions
"Am confused about functions/vi's/express.vi's" "Bit by bit ( it costs me much efforts and time ) I proceed in developing my LabView 7 applications. Though, I am still basically confused about some semantics. When right clicking the Block Diagram, I see icons for : 1. input 2. analysis 3. output 4. exec crt 5. arithmetics / compare 6. signal manipulation 7. user libs 8. functions ## 1/6 contain mostly express.vi's ( blue background ). # 8 contains express.vi's ( blue ) as well as non-express.vi's ( yellow border ) as well as non-vi.functions ( yellow ). ( BTW : am I right in the colors ? ) If " express.vi's " and " sub.vi's " are " functions" , why are those " express.vi's " and " subvi's " not just called " function " instead of " express.vi " and " sub.vi "? On the other hand, if " express.vi's " and " sub.vi's " are NOT functions, why are their icons choosable under " functions " ? If " .vi " is a species of the genus " function " , why are not all " vi's "

json functions
character mapping of > (x)Harbour and UNICODE, but other than that, it looks like reading- > in / writing-out a flat file with no indexing scheme. > > David A. Smith Dear David, I have no knowledge of c, there would be someone who is disposed to help me? or show me the way to call these functions? Thank you so much Pere Dear pcordo: On Feb 23, 7:19=A0am, pcordo <perecordo...@gmail.com> wrote: > On 23 Feb, 14:53, dlzc <dl...@cox.net> wrote: > > On Feb 23, 4:49=A0am, pcordo <perecordo...@gmail.com> wrote: > > > > Someone has... to call > these functions? You can search this newsgroup for instances of "#pragma", to see how C code is embedded in our (x)Harbour code. Doesn't mean you won't need help besides this. You should start with the C function list, and enumerate the "goesintas" (goes in to's) and "comesoutas". That way you'd know what parameters to pass, what "publics" need to be set (hopefully few to none), what values to get back, and what errors look like. Then the ugliness begins. David A. Smith Hi Pere, What is this function

generating functions
hi i hve made a function using a matlab book ... which directory should i use(for putting in the M. file) to make the function work properly regards Hamza, You can put it anywhere on MATLAB path. To add the directory to MATLAB path type pathtool in the command prompt and use the GUI. Igor. "hamza" <hamzamalik@gmail.com> wrote in message news:eef79ab.-1@webx.raydaftYaTP... > hi > i hve made a function using a matlab book ... which directory should > i use(for putting in the M. file) to make the function work properly > regards

membership functions
i am working on a fuzzy system with five inputs.i wish to know if there is any criteria to select the number of membership functions.I could run my program with 2 membership functions for each input.any attempt to run with more membership functions would stall my computer.please help me in this regard.

hash functions
Can someone direct me to fortran source code for popular or effective hashing functions, such as sha1 or md5? This turns out to be hard to search for, because of all the messages mentioning various hashes in headers or sigs. Daniel Feenberg drfremove@nber.org wrote: > Can someone direct me to fortran source code for popular or effective > hashing functions, such as sha1 or md5? This turns out to be hard to > search for, because of all the messages mentioning various hashes in > headers or sigs. Brent's hashing algorithm is implemented in Fortran 90 at http...; hashing functions, such as sha1 or md5? This turns out to be hard to -|> search for, because of all the messages mentioning various hashes in -|> headers or sigs. -| -|Brent's hashing algorithm is implemented in Fortran 90 at -|http://users.bigpond.net.au/amiller/hash.f90 . Herman D. Knoble wrote: > Also see: > > Hash Function (written C) by Bob Jenkins: > http://burtleburtle.net/bob/hash/doobs.html > Hash Tables: http://burtleburtle.net/bob/hash/evahash.html > http://www.cris.com/~Ttwang/tech/inthash.htm > Algorithms from the book: http

Stems and Functions
I have several STEMs that contain data. I would like to write a routine to sort them regardless of the STEM name. It would be nice to write a FUNCTION (or SUBROUTINE, or whatever) to sort any of them. I cannot find a way to write a generalized sort routine that gets passed a STEM name and sorts it. I have not found anything that says that you can pass a STEM name to a FUNCTION and return it once it has been manipulated... Unless I have to use the VALUE function to do this. Thanks, Neal On Fri, 21 Dec 2007 10:47:30 -0500, Neal Eckhardt <neckhardt@penntraffic.nospam.com> wrote: >I ha

Compression Functions
I want to do a quick and dirty scan of Apache logs using some of the zlib Compression Functions. My hosting company tars and gzips several other log files into the gz file. Is there an easy way, using PHP, to separate the files, and only process the Apache log? Hi you can exec this command tar xzvf logs.tar.gz access_log where access_log is the file you want to extract. Regards, John Peters On Apr 28, 9:52 pm, William Gill <nore...@example.com> wrote: > I want to do a quick and dirty scan of Apache logs using some of the > zlib Compression Functions. My hosting company tars and gzips several > other log files into the gz file. Is there an easy way, using PHP, to > separate the files, and only process the Apache log? petersprc wrote: > Hi you can exec this command > > tar xzvf logs.tar.gz access_log > > where access_log is the file you want to extract. > Thanks, but I don't remote access to the shell. I was hoping I could use the PHP compression functions to split the files, extract to a variable, and scan the data. I have been playing with gzfile() but what I'm doing seems a little crude. On 30 Apr, 13:28

blobs functions
Hello Group, Any of you have a pdf handout to learn about blob functions. I made a online search but only academic paper showed up and there is nothing in wikipedia. best regards, eric

Executing functions
Can someone help me understand why Example #1 & Example #2 will run the functions, while Example #3 DOES NOT? Thanks for your time! R.D. def One(): print "running fuction 1" def Two(): print "running fuction 2" def Three(): print "running fuction 3" # Example #1 fList = ["Two()","Three()"] for func in fList: exec func # Example #2 Two() Three() # Example #2 fList = ["Two()","Three()"] for func in fList: func On Feb 11, 9:15=A0am, DataSmash <r...@new.rr.com> wrote: > Can someone help me understand why Example #1 & Example #2 will run > the functions, > while Example #3 DOES NOT? > Thanks for your time! > R.D. > > def One(): > =A0 =A0 print "running fuction 1" > def Two(): > =A0 =A0 print "running fuction 2" > def Three(): > =A0 =A0 print "running fuction 3" > > # Example #1 > fList =3D ["Two()","Three()"] > for func in fList: > =A0 =A0 exec func > > # Example #2 > Two() > Three() > > # Example #2 > fList

Managing Functions
In the course of developing software tools using MATLAB, I've created a lot of helper functions. It's getting to the point where they are difficult to manage because each function has its own file. Is there a way to consolidate all of these functions into a single file without turning them into sub-functions? I would like to be able to call these functions from the console, scripts, or other functions - while sub-functions are inaccessible from outside the file. In short, I'm looking for the MATLAB analog to "#include.." in C. Any and all help is appreciated! Thanks, Jeremiah (to email, please remove XXX, YYY, ZZZ from address) actually, no. best create a folder where you put in all these helper functions, and then add it to your matlab path. you could try merging them into a single file, add a "gateway function", which itself calls the requested sub-functions. but then, this is probably rather slow and ugly. see the below example: file: test.m ------------ function varargout = test(fname,varargin) [varargout{1:nargout}] = feval(fname,varargin{:}); function a = f1(x) a = x.^2; function [a,b] = f2(x,y) a = x; b = y.^2