Jump to content



Photo
- - - - -

Carriage Return And Concatenation


  • Please log in to reply
No replies to this topic

#1 Smola

Smola

    Newbie

  • Members
  • Pip
  • 2 posts

  • Calculators:
    Classpad 330

Posted 04 March 2008 - 03:45 AM

Hey all, I'm trying to write a "simple" program that calculates vector projection (the easy part) and then displays a vector as a sum of orthogonal vectors. With any math calculation the CP generally simplifies completely so my first obstacle was to figure out how to write a sum of vectors like this:

w = [u1 u2] + [v1 v2]

Btw, I am using Input to get the vectors as input so the user can type in new vectors each time. The input uses brackets and commas (i.e. [u1,u2] and [v1,v2]).

However, the only way I can can get the traditional "comma-less" format is by using PrintNatural but that pops up a message box. That wouldn't be horrible if I could figure out how to concatenate more than 2 strings at a time...

Anyway, before I get to that, if I just use print, the vectors come out like this:

[[u1,u2]]
[[v1,v2]]

and I can't figure out how to get rid of the double brackets. I mentioned before that I was just going to find a way out by using concatentation but I would have to use StrJoin so many times it just seems inefficient to me. Does anyone have any ideas? Here is the code I have so far (commented out a couple for testing):

Local u
Local v

ClrText

Input u,"Input first vector [u₁,u₂]:","First Vector"
Input v,"Input second vector (onto) [v₁,v₂]","Second Vector (onto)"

Print u			'this is just to see what the input looks like
Print v

'proj(u,v)⇒w₁
'w₂=u-w₁

ExpToStr u+v,uplusv			'testing concatenation here
StrJoin uplusv,"hi",joined
Print joined





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users