Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Please i really need help with this Lab work - it is killing me

Subject: Please i really need help with this Lab work - it is killing me

From: Moruf

Date: 9 Dec, 2011 03:35:09

Message: 1 of 4

Problem 1: (25 Points) Save as lastname_prob1.m
Ask the user for inputs of the variables start, stop, inc and a. At runtime please enter values of 0, 30, 0.1 and 2, respectively. Plot the equation alt = sin(pi/4) + a•(t-5)2, where a is 2 and t varies from 0 to 30 with a step size of 0.1 in a figure 2. Use an appropriate FOR loop to generate and store the values of t and alt. Add a title, xlabel and ylabel to the plot. Remember to clear at the beginning and pause at the end of the code.


Please can someone help me or explain things to me. I am lost and totally feeling bad with this lab work

que 1. For the same “alt” equation above, use a WHILE loop to solve for the time t (starting from 0) at which alt crosses 600 but this time use inc of 0.01 instead of 0.1. Use the command sprintf to create an output message displaying the time at which this occurs (label your answer clearly). Remember to clear at the beginning and pause at the end of the code.

 
que 2
Write the following user-defined matlab functions:

1. Create the function file lastname_loopspecs.m
This function asks the users for the desired loop specifications.

function [start, stop, inc, a]=lastname_loopspecs()
start=input('Please enter a value for Start: ');
stop=input('Please enter a value for Stop: ');
inc=input('Please enter a value for the Increment: ');
a=input('Please enter the value of a');

2. Create the function file lastname_calc_alt.m
This function calculates the altitude of an object given the equation:
alt = sin(pi/4) + a•(t-5)2.

function alt=lastname_calc_alt(a,t)


Using these two predefined functions and a WHILE loop, find the time t at which alt crosses 600. Set inc to 0.01 and use the same “alt” equation above. Use the command sprintf to create an output message displaying the time at which this occurs (label your answer clearly). Remember to clear at the beginning and pause at the end of the code.

Subject: Please i really need help with this Lab work - it is killing me

From: Jan Simon

Date: 9 Dec, 2011 08:38:08

Message: 2 of 4

Dear Oluakin,

Please stop the cross posting.

Kind regards, Jan

Subject: Please i really need help with this Lab work - it is killing me

From: Steven_Lord

Date: 9 Dec, 2011 14:36:04

Message: 3 of 4



"Moruf " <aridunnu@hotmail.com> wrote in message
news:jbrvld$b2b$1@newscl01ah.mathworks.com...
> Problem 1: (25 Points) Save as lastname_prob1.m
> Ask the user for inputs of the variables start, stop, inc and a. At
> runtime please enter values of 0, 30, 0.1 and 2, respectively. Plot the
> equation alt = sin(pi/4) + a(t-5)2, where a is 2 and t varies from 0 to
> 30 with a step size of 0.1 in a figure 2. Use an appropriate FOR loop to
> generate and store the values of t and alt. Add a title, xlabel and ylabel
> to the plot. Remember to clear at the beginning and pause at the end of
> the code.
>
>
> Please can someone help me or explain things to me. I am lost and totally
> feeling bad with this lab work

If you show what you've already tried, someone may be able to give you some
suggestions. If you're not sure where to even begin, that's a bigger problem
and one that you should discuss with your teacher/professor/TA.

*snip*

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Please i really need help with this Lab work - it is killing me

From: Baalzamon

Date: 13 Dec, 2011 21:58:08

Message: 4 of 4

"Oluakin" wrote in message <jbrvld$b2b$1@newscl01ah.mathworks.com>...
> Problem 1: (25 Points) Save as lastname_prob1.m
> Ask the user for inputs of the variables start, stop, inc and a.
Look up function "input" etc

At runtime please enter values of 0, 30, 0.1 and 2, respectively. Plot the equation alt = sin(pi/4) + a•(t-5)2, where a is 2 and t varies from 0 to 30 with a step size of 0.1 in a figure 2. Use an appropriate FOR loop to generate and store the values of t and alt. Add a title, xlabel and ylabel to the plot. Remember to clear at the beginning and pause at the end of the code.
>
for kk = start:inc:stop

end;

or
myvector = start:inc:stop;
for kk = 1:numel(myvector)
resutl(kk) = ......


For the rest, read the MATLAB basics book....Cross reference with help documentation...
Break your prob down to small steps and try to think up code...
I am quite fond of psuedocode sstyle..
split prbs to small jobs > split jobs into steps > translate into code snippets > expand



e.g.
get inputs > run through range > calc function
a_1...n = input > x=[start:inc:stop] > x(i) = ......

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us