Author |
Message |
|
haun
Advanced Newbie
Joined: 14 Sep 2008 Posts: 54
|
Posted: 28 Sep 2009 10:21:35 pm Post subject: |
|
|
Ok so i discovered the Output() function and am now starting on making my outputs easy to read.
The first major problem i have run into is when i have a set of outputs where some output set strings (aka asdf) and where some output values of variables (aka 1-100000000)
Here is my function with just that example:
Code: Disp "Y=MX+B"
Input "X1=?",W
Input "Y1=?",X
Input "X2=?",Y
Input "Y2=?",Z
(Z-X)/(Y-W)→M
-(M(W))+X→B
ClrHome
Disp "Y=MX+B"
Output(1,1,"Y=")
Output(1,3,M)
Output(1,4,"X")
Output(1,5,"+")
Output(1,6,B)
the problem is when M is > that 2 digits, it blocks the "X+"B part.
is there a way to figure the amount of digits in a certain variable to which i can add to the column output to move the words along?
I looked around a modulo (intValue - (intValue / intDivisor) * intDivisor) (often shown as X%Y) but that wouldnt help.
I know the easy way around this would be to assume that M will never be over Bla amount of digits and just make it 'there' but im not like that.
Thanks for all your help!! |
|
Back to top |
|
|
DarkerLine ceci n'est pas une |
Super Elite (Last Title)
Joined: 04 Nov 2003 Posts: 8328
|
Posted: 28 Sep 2009 10:29:33 pm Post subject: |
|
|
One way to do it would be convert the numbers to strings, using the LinReg method. In your case, the easier thing to do is cheat:
...
{W,Y→L1
{X,Z→L2
LinReg(ax+b) Y1
Equ>String(Y1,Str1
Output(1,1,"Y="+Str1
You don't even need a formula, which depending on what you want is good or bad.
Another option is to use Text( on the graph screen, where you can just do Text(0,0,"Y=",M,"*X+",B.
Last edited by Guest on 05 Jul 2010 08:02:59 am; edited 1 time in total |
|
Back to top |
|
|
dxfan101010
Member
Joined: 31 Mar 2008 Posts: 194
|
Posted: 28 Sep 2009 10:36:58 pm Post subject: |
|
|
or you could do
Code: Disp "Y=MX+B"
Input "X1=?",W
Input "Y1=?",X
Input "X2=?",Y
Input "Y2=?",Z
(Z-X)/(Y-W)→M
-(M(W))+X→B
ClrHome
[[size=4][color=#FF0000]Disp "Y=MX+B"
Output(2,1,"M=
Output(2,3,M)
Output(3,1,"B=
Output(3,3,8)[/[/color][/size]
and just leave the user to plug in the values
Last edited by Guest on 28 Sep 2009 11:09:07 pm; edited 1 time in total |
|
Back to top |
|
|
haun
Advanced Newbie
Joined: 14 Sep 2008 Posts: 54
|
Posted: 28 Sep 2009 10:42:12 pm Post subject: |
|
|
thats what i had last time. |
|
Back to top |
|
|
dxfan101010
Member
Joined: 31 Mar 2008 Posts: 194
|
Posted: 28 Sep 2009 11:01:47 pm Post subject: |
|
|
no I moved b down a row so that it would be
Code: [color=#4169E1]Y=MX+B
M=23
B=15[/color]
This is how linReg(ax+ outputs
Yours does
Code: [color=#0000FF]Y=Mx=B
Y=23x=15[/color]
Last edited by Guest on 28 Sep 2009 11:06:48 pm; edited 1 time in total |
|
Back to top |
|
|
haun
Advanced Newbie
Joined: 14 Sep 2008 Posts: 54
|
Posted: 29 Sep 2009 10:34:15 am Post subject: |
|
|
My original code did the same thing but with the display command.
I want an in-line answer
Code: y=mx+b
as opposed to
Code: m=blah
b=bla
Last edited by Guest on 29 Sep 2009 10:43:26 am; edited 1 time in total |
|
Back to top |
|
|
DrDnar
Member
Joined: 28 Aug 2009 Posts: 116
|
Posted: 29 Sep 2009 02:36:22 pm Post subject: |
|
|
If the number is a whole number, you can get the number of digits in it by taking the log-base-ten of it. For example Code: int(1+log(562
3 Getting the number of digits in the fractional part would be harder. Perhaps you could multiply the number by ten in a loop until fPart(number becomes zero. At that point, though, you might be better off going with the LinReg method of converting the number to string and then doing length( to get the length of the number. |
|
Back to top |
|
|
haun
Advanced Newbie
Joined: 14 Sep 2008 Posts: 54
|
Posted: 29 Sep 2009 04:00:09 pm Post subject: |
|
|
i did see the log() idea on TI|BD but then i realized it wouldnt work with fractions (A/.
Can you go into detail about the converting the numbers into a string and doing the length() thing? |
|
Back to top |
|
|
DarkerLine ceci n'est pas une |
Super Elite (Last Title)
Joined: 04 Nov 2003 Posts: 8328
|
Posted: 29 Sep 2009 04:34:29 pm Post subject: |
|
|
See my post above. There's a link to the general method, if you want to use that, but that code should be even better. |
|
Back to top |
|
|
haun
Advanced Newbie
Joined: 14 Sep 2008 Posts: 54
|
Posted: 29 Sep 2009 04:52:47 pm Post subject: |
|
|
From what I'm understanding, this method will only work for this specific program.
I need a way to do this that will work for any function from quadratics to matrixies. |
|
Back to top |
|
|
DarkerLine ceci n'est pas une |
Super Elite (Last Title)
Joined: 04 Nov 2003 Posts: 8328
|
Posted: 29 Sep 2009 08:19:46 pm Post subject: |
|
|
For that, use the general routine on the page I linked to. |
|
Back to top |
|
|
haun
Advanced Newbie
Joined: 14 Sep 2008 Posts: 54
|
Posted: 01 Oct 2009 11:21:26 am Post subject: |
|
|
If the general routine your talking about is:
Code: :{0,1→L₁
:{0,N→L₂
:LinReg(ax+b) Y₁
:Equ►String(Y₁,Str1
:sub(Str1,1,length(Str1)-3→Str1
then I don't need this. I have a program that will do this.
I need a routine that counts the number of characters in a number or fraction (eg 5 has 1 character, 126 has 3, and 126/189 has 7)
the routine I believe your are linking me to does something I already know how to do, and doesn't count characters. |
|
Back to top |
|
|
DarkerLine ceci n'est pas une |
Super Elite (Last Title)
Joined: 04 Nov 2003 Posts: 8328
|
Posted: 01 Oct 2009 12:52:27 pm Post subject: |
|
|
But once you convert a number to a string, you can count the characters very easily - just length() of the string! Not to mention that you can avoid counting characters entirely by adding strings together in a suitable way. |
|
Back to top |
|
|
haun
Advanced Newbie
Joined: 14 Sep 2008 Posts: 54
|
Posted: 01 Oct 2009 04:22:17 pm Post subject: |
|
|
true, but it does not keep fractions, for instance when M=(1/126) it returns .0079365079 instead of 1/126. |
|
Back to top |
|
|
dxfan101010
Member
Joined: 31 Mar 2008 Posts: 194
|
Posted: 01 Oct 2009 04:54:39 pm Post subject: |
|
|
Than add the M►Frac to get 1/126
Last edited by Guest on 01 Oct 2009 04:55:02 pm; edited 1 time in total |
|
Back to top |
|
|
haun
Advanced Newbie
Joined: 14 Sep 2008 Posts: 54
|
Posted: 01 Oct 2009 05:19:52 pm Post subject: |
|
|
this is for within the routine. It only outs decimals into the string. If im counting characters decimals with a char value of 11 would not do well with a fraction with a char value of 5.
if you were wondering about my thing with fractions: It just makes it easier for the user to read the information. |
|
Back to top |
|
|
haun
Advanced Newbie
Joined: 14 Sep 2008 Posts: 54
|
Posted: 01 Oct 2009 07:06:15 pm Post subject: |
|
|
i guess this went from moving the output to finding a way to put fractions from variables into Strings....
every thing else is easy |
|
Back to top |
|
|
DarkerLine ceci n'est pas une |
Super Elite (Last Title)
Joined: 04 Nov 2003 Posts: 8328
|
Posted: 01 Oct 2009 08:12:40 pm Post subject: |
|
|
If you want to do anything complicated with fractions, see this routine. |
|
Back to top |
|
|
|