#### unit step , ramp functions

```hello am trying to create new unit step and unit ramp function using matlab language and use them to get a plot for a specific equation

i have created the the code below but still getting some errors that i cannot identify..

function k=step(t)

k = t>=0;

function k = ramp(t)

if t >= 0
k=t;
else
t<0
k=0;
end

t=-5:5;

f = zeros(size(t));

for x = 1:length(t)

f(t)= (5*ramp(t+3))- ramp(t+1) - (3.*ramp(t))+ (5*ramp(t-1)) + (3*step(t-2));

end

plot(t,f)

```
 0
kailatzakis
12/22/2010 8:11:20 PM
comp.soft-sys.matlab 208217 articles. 7 followers. lunamoonmoon (258) is leader.

4 Replies
4143 Views

Similar Articles

[PageSpeed] 4
```On 10-12-22 02:11 PM, kailatzakis wrote:
> hello am trying to create new unit step and unit ramp function using matlab
> language and use them to get a plot for a specific equation
> i have created the the code below but still getting some errors that i cannot
> identify..
>
> function k=step(t)
>
> k = t>=0;
>
> function k = ramp(t)
>
> if t >= 0 k=t;
> else
> t<0
> k=0;
> end
>
> t=-5:5;
>
> f = zeros(size(t));
>
> for x = 1:length(t)
> f(t)= (5*ramp(t+3))- ramp(t+1) - (3.*ramp(t))+ (5*ramp(t-1)) + (3*step(t-2));
>
> end
>
>
> plot(t,f)
>

Change the assignment from f(t) on the left hand side to f(x) on the left hand
side.

Also, I would point out that your ramp function is equivalent to max(0,t) . If
you were to change it to that, then both step() and ramp() would be vectorized
and you would then not need a loop to calculate your f.
```
 0
Walter
12/22/2010 8:42:48 PM
```"kailatzakis " <pns2050@yahoo.com> wrote in message <ietm18\$j2n\$1@fred.mathworks.com>...
> hello am trying to create new unit step and unit ramp function using matlab language and use them to get a plot for a specific equation
>
> i have created the the code below but still getting some errors that i cannot identify..
>
> function k=step(t)
>
> k = t>=0;
>
> function k = ramp(t)
>
> if t >= 0
>     k=t;
> else
>     t<0
>     k=0;
> end
>
> t=-5:5;
>
> f = zeros(size(t));
>
> for x = 1:length(t)
>
>     f(x)= (5*ramp(t+3))- ramp(t+1) - (3.*ramp(t))+ (5*ramp(t-1)) + (3*step(t-2));
>
>
> end
>
>
> plot(t,f)
>
>

yes i identified this mistake but still getting this error ..

???  In an assignment  A(I) = B, the number of elements in B and
I must be the same.

Error in ==> rampstep at 7
f(x)= (5.*ramp(t+3))- ramp(t+1) - (3.*ramp(t))+ (5.*ramp(t-1)) +
(3.*step(t-2));
```
 0
kailatzakis
12/22/2010 8:54:07 PM
```On 10-12-22 02:54 PM, kailatzakis wrote:

> yes i identified this mistake but still getting this error ..
>
> ??? In an assignment A(I) = B, the number of elements in B and
> I must be the same.
>
> Error in ==> rampstep at 7
> f(x)= (5.*ramp(t+3))- ramp(t+1) - (3.*ramp(t))+ (5.*ramp(t-1)) +
> (3.*step(t-2));

All the "t" on the right hand side should be "x".
```
 0
Walter
12/22/2010 9:04:17 PM
```Given a current step function:

T= 1e-9 * input('  simulated time [ns]: ');   		% simulated time [s]
disp(dt);
ct = round(T/dt); # time elements
t=0:dt:ct*dt;									% time vector
Ion=1e-3*input('  DC max current [mA]: ');		% DC current [A]
I=repmat(Ion, [1, ct+1]);
I(1,1)=0;

how can I make a ramp function?
```
 0
3/3/2013 3:56:18 AM
Similar artilces about - unit step , ramp functions:

Functional Dependency to constrain a relation to exactly one element?
It's easy enough to describe a functional dependency that will constrain a relation to having at most one row; it is any functional dependency for which the determinant set is empty. In other words, for any relation R with set-of-attributes A, if you have a function dependency {} -> any subset of A then R may have at most one element. Is it possible to have a functional dependency that will constrain R to *exactly* one row? I seem to remember Vadim saying it was possible to use FDs to enforce any cardinality bounds (upper and lower?) but I didn't understand it a...

medini unite new release 1.2.3
For your info: We've just release medini unite 1.2.3 a very powerfull and user frendly Diff and merge tool for simulink and stateflow models. medini unite is a new generation tool allowing comparing and merging MATLAB Simulink and Stateflow models. Key features: - compare graphically any MATLAB Simulink models and any Stateflow models - merge the differences into a target model and generate merge reports - 3 Way diff/merge (ancestor/source/target) - dSpace Targetlink support and IBM Rational Clearcase integration - single user / dongle / floating license models http://www.ik...

im working on lms algorithm i want to use the lms function to update my filter coefficients instead of this :"w = w + mu * u * e(n)" any help please? ...

Unit Test in LV
Are there any unit test tools for LV?.&nbsp; I'm looking for something like NUnit. &nbsp; Bill F A company called TimeSlice makes a tool called OverVIEW/UTool.&nbsp; The address is <a href="http://www.tslice.com" target="_blank">www.tslice.com</a>. I check this link and it is listed as expired, so I contacted the company.&nbsp; I'll let you know what I find out. Tom Hi Bill, &nbsp; It sounds like what you are looking for is our software product called TestStand. Basically TestStand is a fully customizable, off-the-shelf test mana...

PEP 11 update
I made a quick update to PEP 11, "Removing support for little used platforms". I added details about ending support for AtheOS/Syllable and BeOS. I also added a yet-to-be-fleshed out section entitled "Platform Maintainers". I intend that to the extent possible we document the responsible parties for various platforms. Obviously, common platforms like Windows, Mac OS X, Linux and common Unix platforms (Solaris, *BSD, what else?) will continue to be supported by the core Python developer community, but lesser platforms should have one or more champions, and we...

Ann: ESBUnitConv v7.2
ESB Consultancy is pleased to announce the latest release of our freeware Unit Conversion Software for Windows. Now supplies 582 Units in 21 different Measurement Categories. http://www.esbconsult.com/esbcalc/esbunitconv.htm This latest release adds more conversions as well as a number of minor improvements. Glenn Crouch mailto:glenn@esbconsult.com ESB Consultancy http://www.esbconsult.com Home of ESBPCS & ESB Calculators Kalgoorlie-Boulder, Western Australia ...

Re: Need advice on using a macro inside a data step array loop #7
Hi Peter and Joe, Joe, I don't think Peter is interested in how _not_ to do it, or in the advice to start learning quit some amount of new stuff. I have the impression that such advice almost always is the way you respond. But Peter wants a constructive, substantial answer. So you should either have provided a concrete solution with SCL or you should not have responded at all. (Sorry Peter.) Instead I will give two solutions to Peter here, one using CALL EXECUTE and another one using macro. I think CALL EXECUTE is more appropriate here; this is an approach in which you can embed a (one o...

fitting function
Hi, I have a function y=a/(b+exp(c+dx))+e; I have two known x and y vectors. Can you help me how to derive a, b, c, d and e after fitting this function to x and y. Thanks! Hi, You have to read the curve fitting toolbox of MATLAB for solving your problem. some hint: load your data in workspace type cftool on command window and enjoy ................................ On Sep 25, 3:08=A0am, "Young Ryu" <ryuy...@gmail.com> wrote: > Hi, > > I have a function > > y=3Da/(b+exp(c+dx))+e; > > I have two known x and y vectors. Can you help me how to derive a...

step funtion
Would someone be able to help me with this. I have been trying to get this code going and at one time long time ago it worked. Now it doesnt after reinstall of matlab. Can someone give me some guidance as to how I can make this code work again. Thanks. function [u] =step(t) % unit step function % for all t less than 0 make u = 0 % for all t greater than or equal to 0 make u = 1 u = zeros(size(t)); % zero fill size of t, zero fill=(t_upper_lim-t_lower_lim)/0.001 u(find((t)>=0))=1; %return indices of elements of t >=0 that and sets them to 1 THIS IS THE ERROR MESSAGE ?? Inp...

How to do unit test on an atom unit which tied with a large unit?
Part of the object hierarchy in my program seems like this, 1, A manager class (the largest unit), it contains a list of the atom units and some global information needed by the atom units. 2, An atom class list which is a bridge of the manager and the atom. 3, Atom class (the smallest unit). The atom class logical is reasonably simple and independent, so major part of it can be test without trouble. However, some parts of the atom class require informations from the manager class. Those informations are global, and some informations are only available during certain session such as the user ...

Job: United States - Texas - San Antonio
Programmer/Analyst I position available at the University of Texas at San Antonio http://www.utsa.edu/hr/jobs/utsajobs.cfm Job posting closes June 7, 2004 Note - The salary for this job is \$30,000. "Jeffrey Jordan" <jeffjordan@myrealbox.com> wrote in message news:c8tgkd\$af7\$1@news.tamu.edu... > Programmer/Analyst I position available at the University of Texas at San > Antonio > > http://www.utsa.edu/hr/jobs/utsajobs.cfm > > Job posting closes June 7, 2004 > > ...

Break Function
The break function only takes you out of a single for loop. Suppose one has two for loops and one if with an else statement which contains a break.How does one get out of both 'for' loops with one statement??? e.g. xe=10; for k=1:10 for f=1:7 xe=xe+k xe2=xe+f if xe<=20 display('1on'); else break break end end end Obviously this does not work.Any ideas before i do this: xe=10; for k=1:10 for f=1:7 xe=xe+k xe2=xe+f test=1; if xe<=20 display(&...

I run out of heap during unit tests
I use lisp-unit and so far I was pleased with it. In order to refactor a big chunk of code I decided to write some tests. I have written a function called loader-data, which works fine in repl. However when I run (run-tests :all) SBCL runs out of heap and I get an error. I'm a Lisp noob, so the problem likely lies with my code. Depending on the code in test heap is exhausted every first time I run the test, or after repeatedly running the same test. I was running my function directly in repl over and over again and didn't notice such behaviour. Do you have any idea ho...

Re: Howto pass a callback function to call library function node #2
I would, personally, use the occurance approach. &nbsp; In the DLL have a callback to get notified of when the progressbar needs to be adjusted.&nbsp; In this callback use an occurance to tell LabVIEW the new values ready to be read.&nbsp; Also have a helper (reader) function that LabVIEW can call to get the most current value... &nbsp; Basically every time the LabVIEW occurance is triggered call the DLL for the new value.&nbsp; To me this seems the easiest way. &nbsp; Oooo, new forum message interface!&nbsp; I like it!&nbsp; :robottongue: &lt;--- First robo...

US-CA-San Bruno: Oracle, Functional GL/Project Acct./iExpense; 6M (45298332405)
US-CA-San Bruno: Oracle, Functional GL/Project Acct./iExpense; 6M (45298332405) =============================================================================== Position: Oracle Reference: SMC01381 Location: San Bruno CA Duration: 6M Skills: Strong functional GL/Project Accounting/iExpense resource. Please send your current resume in confidence to <staffing@eurosoft-inc.com> ..45298332405. ...

Running GA command in Matlab with output of Simulink model as an objective function of optimization
Hi I am trying to run GA command in MATLAB for the optimization of vehicle suspension parameters.The objective function is RMS acceleration of vehicle subjected to road excitation.RMS acceleration is the response of Simulink model which needs to be passed in MATLAB continuously in conjuction with GA. Please Help me! On 10/15/2010 7:25 AM, Chaitanya Vichare wrote: > Hi > I am trying to run GA command in MATLAB for the optimization of vehicle > suspension parameters.The objective function is RMS acceleration of > vehicle subjected to road excitation.RMS acceleration is the re...

Re: printing the results at each step of the program #3 1554373
On Thu, 1 Jun 2006 19:01:23 -0700, skyline <carf4F@GMAIL.COM> wrote: >Hello, > >I would like to print the results at each step of the program to make >sure that >the results are correct. For example > >data data1; >set data1; >variable1=variable1+1; >run; > >proc print data=data1; >title ''; >run; > >data data1; >set data1; >variable2=variable1+1; >proc print data=data1; >run; > >when I have many steps like this, it is not always easy to read the lst >file to see which outputs are from which proc print. Is ther...

Forms Customization
Hi , I have customized a for in Oracle application and registered the for withing application. Now i want to enable QUERY_FIND functionality for this form. I am new to form customization. Can some one please help and tell me the steps for doing query_find in Forms. Thanks Prashant Pathak navikp@gmail.com wrote: > Hi , > > I have customized a for in Oracle application and registered the for > withing application. > > Now i want to enable QUERY_FIND functionality for this form. > > I am new to form customization. Can some one please help and ...

Remote Function Call
Hi, I have two machines. A python program on machine 1 needs to make a python call to a method in machine 2. What is the most efficient / fast / programmer friendly way to do it? - XML-RPC? - Http Call? Thanks, Mike Mike wrote: > Hi, > > I have two machines. A python program on machine 1 needs to make a > python call to a method in machine 2. What is the most efficient / fast > / programmer friendly way to do it? > > - XML-RPC? > - Http Call? use Pyro http://pyro.sourceforge.net --Irmen Sounds like what I need. Thanks Irmen. I heard google uses python with mul...

Re: Multiply 2 matrices where one contains differential operators with one that contains functions of x and y
ref (me) >This is my solution: > > > A = {{D[#1, x] & , 0 & }, {0 & , D[#1, y] & }, {D[#1, y] & , D[#1, x] > & }} > B = {{x*y, x^3*y, 3*x + y^2}, {2*x, x^4*y, y^2}} > > {rowsA, colsA} = Dimensions[A]; > {rowsB, colsB} = Dimensions[B]; > > r = Table[0, {rowsA}, {colsB}]; (*where the result of A.B goes *) > > For[i = 1, i <= rowsA, i++, > For[j = 1, j <= colsB, j++, > For[ii = 1, ii <= rowsB, ii++, > r[[i,j]] = r[[i,j]] + A[[i,ii]] /@ {B[[ii,j]]} > ] > ...

Cannot covert non-static member function to normal function?