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:
A function for a vector...

Subject: A function for a vector...

From: Don

Date: 22 Sep, 2010 23:21:25

Message: 1 of 7

Ok the first part was easy enough to figure out but B and C are rather tricky...I just need a push in the right direction if possible...Any help is greatly apprecaited it. Thanks...

[URL=http://img17.imageshack.us/i/functionw.jpg/][IMG]http://img17.imageshack.us/img17/6862/functionw.jpg[/IMG][/URL]

Subject: A function for a vector...

From: John D'Errico

Date: 22 Sep, 2010 23:44:10

Message: 2 of 7

"Don " <don.jackson@coker.edu> wrote in message <i7e31l$k5e$1@fred.mathworks.com>...
> Ok the first part was easy enough to figure out but B and C are rather tricky...I just need a push in the right direction if possible...Any help is greatly apprecaited it. Thanks...
>
> [URL=http://img17.imageshack.us/i/functionw.jpg/][IMG]http://img17.imageshack.us/img17/6862/functionw.jpg[/IMG][/URL]

Here is a push - start writing.

Subject: A function for a vector...

From: Don

Date: 22 Sep, 2010 23:45:25

Message: 3 of 7

"Don " <don.jackson@coker.edu> wrote in message <i7e31l$k5e$1@fred.mathworks.com>...
> Ok the first part was easy enough to figure out but B and C are rather tricky...I just need a push in the right direction if possible...Any help is greatly apprecaited it. Thanks...
>
> [URL=http://img17.imageshack.us/i/functionw.jpg/][IMG]http://img17.imageshack.us/img17/6862/functionw.jpg[/IMG][/URL]


Why is the link to the image broken...?

Subject: A function for a vector...

From: Sean

Date: 23 Sep, 2010 00:36:29

Message: 4 of 7

"Don " <don.jackson@coker.edu> wrote in message <i7e4el$hpb$1@fred.mathworks.com>...
> "Don " <don.jackson@coker.edu> wrote in message <i7e31l$k5e$1@fred.mathworks.com>...
> > Ok the first part was easy enough to figure out but B and C are rather tricky...I just need a push in the right direction if possible...Any help is greatly apprecaited it. Thanks...
> >
> > [URL=http://img17.imageshack.us/i/functionw.jpg/][IMG]http://img17.imageshack.us/img17/6862/functionw.jpg[/IMG][/URL]
>
>
> Why is the link to the image broken...?

http://img17.imageshack.us/img17/6862/functionw.jpg works

Well C is straight forward once you have B. You need to know how to write a function, i.e. take input and give output. It's late and I'm feeling nice so here's a hint:

function [out1 out2] = my_new_superAWESOME_function(in1,in2)
   out1 = in1/100
   out2 = out1*in1
end

So now instead of doing the useless computation that I did inside the function; write what you need for yours. What is the norm? How would you calculate the norm of in1?

What happens if you type:
help norm
into the command window.

Also take a look at:
help function_handle
since this is a really easy one line computation.

Subject: A function for a vector...

From: Don

Date: 23 Sep, 2010 11:58:04

Message: 5 of 7

"Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <i7e7ed$qjc$1@fred.mathworks.com>...
> "Don " <don.jackson@coker.edu> wrote in message <i7e4el$hpb$1@fred.mathworks.com>...
> > "Don " <don.jackson@coker.edu> wrote in message <i7e31l$k5e$1@fred.mathworks.com>...
> > > Ok the first part was easy enough to figure out but B and C are rather tricky...I just need a push in the right direction if possible...Any help is greatly apprecaited it. Thanks...
> > >
> > > [URL=http://img17.imageshack.us/i/functionw.jpg/][IMG]http://img17.imageshack.us/img17/6862/functionw.jpg[/IMG][/URL]
> >
> >
> > Why is the link to the image broken...?
>
> http://img17.imageshack.us/img17/6862/functionw.jpg works
>
> Well C is straight forward once you have B. You need to know how to write a function, i.e. take input and give output. It's late and I'm feeling nice so here's a hint:
>
> function [out1 out2] = my_new_superAWESOME_function(in1,in2)
> out1 = in1/100
> out2 = out1*in1
> end
>
> So now instead of doing the useless computation that I did inside the function; write what you need for yours. What is the norm? How would you calculate the norm of in1?
>
> What happens if you type:
> help norm
> into the command window.
>
> Also take a look at:
> help function_handle
> since this is a really easy one line computation.




Ok is this correct...?

vector = @(x) x/norm(x)

vector(v)


or am i way off?

Subject: A function for a vector...

From: Sean

Date: 23 Sep, 2010 13:41:18

Message: 6 of 7

"Don " <don.jackson@coker.edu> wrote in message <i7ffcc$2f5$1@fred.mathworks.com>...
> "Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <i7e7ed$qjc$1@fred.mathworks.com>...
> > "Don " <don.jackson@coker.edu> wrote in message <i7e4el$hpb$1@fred.mathworks.com>...
> > > "Don " <don.jackson@coker.edu> wrote in message <i7e31l$k5e$1@fred.mathworks.com>...
> > > > Ok the first part was easy enough to figure out but B and C are rather tricky...I just need a push in the right direction if possible...Any help is greatly apprecaited it. Thanks...
> > > >
> > > > [URL=http://img17.imageshack.us/i/functionw.jpg/][IMG]http://img17.imageshack.us/img17/6862/functionw.jpg[/IMG][/URL]
> > >
> > >
> > > Why is the link to the image broken...?
> >
> > http://img17.imageshack.us/img17/6862/functionw.jpg works
> >
> > Well C is straight forward once you have B. You need to know how to write a function, i.e. take input and give output. It's late and I'm feeling nice so here's a hint:
> >
> > function [out1 out2] = my_new_superAWESOME_function(in1,in2)
> > out1 = in1/100
> > out2 = out1*in1
> > end
> >
> > So now instead of doing the useless computation that I did inside the function; write what you need for yours. What is the norm? How would you calculate the norm of in1?
> >
> > What happens if you type:
> > help norm
> > into the command window.
> >
> > Also take a look at:
> > help function_handle
> > since this is a really easy one line computation.
>
>
>
>
> Ok is this correct...?
>
> vector = @(x) x/norm(x)
>
> vector(v)
>
>
> or am i way off?

That's correct. Now whether that's what you're instructor wanted or not - another story.

Subject: A function for a vector...

From: Steven_Lord

Date: 23 Sep, 2010 14:03:58

Message: 7 of 7



"Don " <don.jackson@coker.edu> wrote in message
news:i7ffcc$2f5$1@fred.mathworks.com...

*snip*

> Ok is this correct...?
> vector = @(x) x/norm(x)
>
> vector(v)
>
> or am i way off?

Why not test this with a vector for which you know the answer? Since this
looks like a problem from a textbook, I'd guess there are probably
worked-out examples one or more of which may deal with creating unit
vectors.

Alternately, take a unit vector and multiply it by some scale factor, then
try your code on the resulting vector and make sure you receive the unit
vector you started with as the output. If you don't, then there's a
problem. If you do, that's evidence in favor of your code being correct,
but you should try other vectors to increase your confidence until you're
satisfied.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for 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