Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Simple vector => to scalar in Matlab?

  1. Apr 23, 2010 #1
    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.
  2. jcsd
  3. Apr 24, 2010 #2


    User Avatar
    Science Advisor
    Gold Member

    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.
  4. Apr 26, 2010 #3
    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.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Threads - Simple vector scalar Date
LaTeX \vec command Jan 31, 2018
Simple MATLAB loop Oct 30, 2015
Coding up a simple geometric algebra in MATLAB Oct 12, 2015
WolframAlpha miscalculates a simple arithmetic expression May 25, 2015
Vectorization of simple loops Mar 26, 2009