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

    Born2bwire

    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.
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook