Simple vector => to scalar in Matlab?

  • Context: MATLAB 
  • Thread starter Thread starter rx78
  • Start date Start date
  • Tags Tags
    Matlab Scalar Vector
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 11K views
rx78
Messages
2
Reaction score
0
Is there a basic function that renders a vector into its scalar component (ie, turning r1 vector into just r1) in matlab? Trying to simplify some code.
 
Physics news on Phys.org
Best you can do I think is to just grab the element that you want, say if it's the nth element,
r1temp = r1(n);

And then clear r1 to delete it. I don't know if you can do:
r1 = r1(n);

and have r1 reassign itself as a scalar. I think it would work but I do not have access to the license server to try it out on my own copy of Matlab at the moment.
 
Yeah, r1 = r1(n) works as well, just tested it.

Im not sure about this question.. "Is there a basic function that renders a vector into its scalar component" - a vector will generally have more than one scalar component. Maybe if you give an example of your code it will be easier to help.