Menu

#10 num2str does not work as in matlab

open
Functions (19)
5
2006-05-16
2006-05-16
No

num2str needs to work like matlab (originally it worked
like _char,char)

Discussion

  • Jason Height

    Jason Height - 2007-08-14

    Logged In: YES
    user_id=320205
    Originator: NO

    num2str:

    This can return a matrix in matlab. The current code does not allow for this.

    Test cases to be included (ignoring whitespace differences):

    num2str(49) -> "49"
    num2str(49.0) -> "49"
    num2str(49.01) -> "49.01"
    num2str([ 1 2 3]) -> "1 2 3"
    num2str([ 1.0 2.0 3; 4.01 5 6.02]) -> "1 2 3"
    "4.01 5 6.02"

    Stefan, can you confirm this should be done by returning a MatrixToken (which then wraps CharToken's) from the num2str class in the case of a matrix result. For a single result i will simply return a CharToken.

    If so then i can create a patch and also update the test cases.

    Jason

     
  • Jason Height

    Jason Height - 2007-08-15

    Logged In: YES
    user_id=320205
    Originator: NO

    CVS has a patch which uses MatrixToken (which then wraps CharToken's), but the results are not as i expected.

    From what i can deduce i think that i need to create a StringToken which holds a vector of CharToken's. Will give that a go.

     
  • Nobody/Anonymous

    Logged In: NO

    Ok i get it now. Patch to come shortly. Sorry for confusion.

    Jason

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.