Got Questions? Get Answers.
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:
Input Question

Subject: Input Question

From: William

Date: 22 Jul, 2010 15:32:06

Message: 1 of 6

Hello,

I am trying to write a function that will take input from a user and put it into equations then graph plots of these equations. Here is what I have so far.


reply1 = input('Please enter the velocity of the projectile.: ','s');
velocity = reply1
reply2 = input('enter the angle of trajectory.: ','s');
angle = reply2
reply3 = input('enter the position of elevation.: ','s');
postion = reply3

x=(velocity.*cos(angle));
y=position+(velocity.*sin(angle))-((1/2).*9.18);

plot(x,y);

Subject: Input Question

From: Sean

Date: 22 Jul, 2010 16:25:05

Message: 2 of 6

"William " <william.baxter@oit.edu> wrote in message <i29o9l$8b3$1@fred.mathworks.com>...
> Hello,
>
> I am trying to write a function that will take input from a user and put it into equations then graph plots of these equations. Here is what I have so far.
>
>
> reply1 = input('Please enter the velocity of the projectile.: ','s');
> velocity = reply1
> reply2 = input('enter the angle of trajectory.: ','s');
> angle = reply2
> reply3 = input('enter the position of elevation.: ','s');
> postion = reply3
>
> x=(velocity.*cos(angle));
> y=position+(velocity.*sin(angle))-((1/2).*9.18);
>
> plot(x,y);

And your question is...?

Subject: Input Question

From: William

Date: 22 Jul, 2010 23:09:03

Message: 3 of 6

Hi agian my question is reguarding the error I am recieveing sorry i didnt include it earlier. (was in a hurry)

reply1 = input('Please enter the velocity of the projectile.: ','s');
velocity = reply1
reply2 = input('enter the angle of trajectory.: ','s');
angle = reply2
reply3 = input('enter the position of elevation.: ','s');
postion = reply3

velocity = reply1
position = reply3
angle = reply2
t = length(x)


x=((velocity).*cos(angle).*t);
y=position+((velocity).*sin(angle).*t)-((1/2).*(9.18).*t.^2);

plot(y);

ERROR>>??? Undefined function or variable "x".

Subject: Input Question

From: Walter Roberson

Date: 22 Jul, 2010 23:29:53

Message: 4 of 6

William wrote:
> Hi agian my question is reguarding the error I am recieveing sorry i
> didnt include it earlier. (was in a hurry)
>
> reply1 = input('Please enter the velocity of the projectile.: ','s');
> velocity = reply1
> reply2 = input('enter the angle of trajectory.: ','s');
> angle = reply2
> reply3 = input('enter the position of elevation.: ','s');
> postion = reply3
>
> velocity = reply1
> position = reply3
> angle = reply2
> t = length(x)
>
>
> x=((velocity).*cos(angle).*t);
> y=position+((velocity).*sin(angle).*t)-((1/2).*(9.18).*t.^2);
> plot(y);
> ERROR>>??? Undefined function or variable "x".


This surprises you when you ask for the length() of x before you define x ?

By the way: as you are asking for string inputs, your "velocity" variable will
be a string, as will be your "angle" and "position" variables. What does it
mean to take the cosine of a string of characters ?

Subject: Input Question

From: William

Date: 22 Jul, 2010 23:50:08

Message: 5 of 6

reply1 = input('Please enter the velocity of the projectile.: ','s');
v = reply1
reply2 = input('enter the angle of trajectory.: ','s');
a = reply2
reply3 = input('enter the position of elevation.: ','s');
p = reply3

x=(v*cos(a)).*t;
y=pos+(v*sin(a))-((1/2).*9.18*t.^2);

v=reply1
a=reply2
p=reply3
t=length(x)


Hello,

Im not sure i under stand your question fully? Taking the cosine of a string will make a set of calculations, and there for data points?

Subject: Input Question

From: Walter Roberson

Date: 23 Jul, 2010 05:58:11

Message: 6 of 6

William wrote:

 > reply2 = input('enter the angle of trajectory.: ','s');
 > a = reply2

> Im not sure i under stand your question fully? Taking the cosine of a
> string will make a set of calculations, and there for data points?

Suppose the user had entered

pi/4

at the angle prompt. Are you expecting that cos(pi/4) would be
calculated? Because that isn't what your code would do: it would instead
calculate cos('pi/4'), and which would be the same as

[cos('p') cos('i') cos('/') cos('4')]

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