how to use the sin function

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

how to use the sin function

ソリューションへジャンプ
2,332件の閲覧回数
subbaraju
Contributor I
hi
i want to use the sine and cosine functions for my project implementaion. as i am new to codewarrior can any one help me in using the sin functions and printf statements i am working on m68hc12dp256 evaluation board.
i tried the following code
# include
void main(void){
int i=1; double y[10];
for(i=1;i10;i++){
y[i]=double (sin (double i));
}
}
if i try to compile it, giving errors saying error: c2450 expected .* + - etc., (expected 'double*' instead of 'double'); what it is meaning
secondly
i am not able to implement the printf statement?

thanking you in advance.

quick response is required.

regards
Subbaraju P.
ラベル(1)
タグ(1)
0 件の賞賛
1 解決策
1,080件の閲覧回数
CrasyCat
Specialist III
Hello
 
According to the code snippet you sent over, y is a local variable. is that right?
 
The table will take a lot of space on the stack, which might overflow.
 
Can you try to either define a bigger stack in the .prm file or define the table as a global variable.
 
Is that working better?
.
CrasyCat

元の投稿で解決策を見る

0 件の賞賛
4 返答(返信)
1,080件の閲覧回数
J2MEJediMaster
Specialist I
It's not clear from your code, but do you include math.h to define the sin/cos functions? Also, make sure that you're linking the correct library that contains both the trigonometric functions and the printf code. Check the readme.txt files that accompany the libraries in the lib directory for more information on what functions each library file contains.

---Tom
0 件の賞賛
1,079件の閲覧回数
subbaraju
Contributor I


J2MEJediMaster wrote:
It's not clear from your code, but do you include math.h to define the sin/cos functions? Also, make sure that you're linking the correct library that contains both the trigonometric functions and the printf code. Check the readme.txt files that accompany the libraries in the lib directory for more information on what functions each library file contains.

---Tom


Thanks for your help now i am able to work with sine function. but i am facing the problem of memory. for the same program if i increase the array size of y to 20 then in debugging it is indicated that no memory FFe:2 at the bottom and the debugging is not proceding. please suggest a possible solution to the problem.
thanking you.
0 件の賞賛
1,081件の閲覧回数
CrasyCat
Specialist III
Hello
 
According to the code snippet you sent over, y is a local variable. is that right?
 
The table will take a lot of space on the stack, which might overflow.
 
Can you try to either define a bigger stack in the .prm file or define the table as a global variable.
 
Is that working better?
.
CrasyCat
0 件の賞賛
1,080件の閲覧回数
CompilerGuru
NXP Employee
NXP Employee
>y[i]=double (sin (double i));


I guess this should just be
y[i]=sin(i);


Why those extra double's?

About printf, is your problem a link time error of not finding TERMIO_PutChar?
If so, search this forum for TERMIO_PutChar.
To use printf with doubles, also make sure your STACKSIZE in the prm is big enough.

Daniel
0 件の賞賛