Qbasicnews.com
July 25, 2021, 01:35:39 PM
 Pages: [1]
 Author Topic: thanx guys for help! need some more here basic on last one.  (Read 2466 times)
shuango
New Member

Posts: 8

 « on: March 20, 2003, 03:56:28 PM »

graph sin(x) and cos(x) on the scale, with  X axis and Y axis, also the graph can change by inputing the phase shift and amplitude.      Y=a*sin(x-2) like that. is that possible to do??
 Logged
toonski84
__/--\__

Posts: 2567

 « Reply #1 on: March 20, 2003, 07:57:07 PM »

please only post these in one forum.  check the other one for my reply.
 Logged

i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Dex4now
Member

Posts: 75

 « Reply #2 on: March 20, 2003, 08:42:41 PM »

Well, you can do this as long as you realize that QB only works with radians, and I assume, you're using degree's. So, your formula becomes:

Code:

Y = a * SIN(((x * (180 / 3.14159)) - (2 * (180 / 3.14159)))

It would, of course, be easier to do the conversion to radians first:
We'll assume your number 2 is a variable called t.

Code:

trad = t * (180 / 3.14159)
xrad = x * (180 / 3.14159)

Thats one way!

Dex
 Logged
Glenn
I hold this place together

Posts: 786

 « Reply #3 on: March 20, 2003, 09:32:34 PM »

You multiply degrees by PI / 180 to convert to radians.  And you can also just do

(X - 2) * PI / 180

and only make one conversion.

Quote from: "Dex4now"
Well, you can do this as long as you realize that QB only works with radians, and I assume, you're using degree's. So, your formula becomes:

Code:

Y = a * SIN(((x * (180 / 3.14159)) - (2 * (180 / 3.14159)))

It would, of course, be easier to do the conversion to radians first:
We'll assume your number 2 is a variable called t.

Code:

trad = t * (180 / 3.14159)
xrad = x * (180 / 3.14159)

Thats one way!

Dex
 Logged

ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Glenn
I hold this place together

Posts: 786

 « Reply #4 on: March 20, 2003, 09:35:12 PM »

http://www.geocities.com/gstumpff/graph.zip

is a QB routine to plot xy data.  Right now, it's set up to read xy data from a file and plot that.  If you want to use it, I'll leave it to you to modify it to just generate the sin(x) data instead of reading it in.
 Logged

ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Dex4now
Member

Posts: 75

 « Reply #5 on: March 20, 2003, 10:59:33 PM »

I looked it up in the "book" first and still managed to transpose the numbers!    :oops:

Thanks Glenn,  too bad the spell-checker can't do math!    :-?

Dex
 Logged
Glenn
I hold this place together

Posts: 786

 « Reply #6 on: March 20, 2003, 11:47:49 PM »

at least do *that*.    )
 Logged

ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
 Pages: [1]