How to do this?.. new to matlab
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
First hey to everybody :)
I am new with Matlab and we have to do for homework some programs to create but i don't know really how to do it.. I had been reading on other forums and youtube but didn't see anything usefull... I would be very grateful if somebody could write me this program to help me. Program:
I have to calculate function sin(x) with help of line on 6 decimals exactly and value compare with Matlab function. Do the same for cos(x)..
sin(x)=x/1!-x^2/3!+x^5/5!-x^7/7!+⋯ and cos(x)= 1-x^2/2!+x^4/4!-x^6/5!+⋯
Please if somebody can help :) Thank you in advance.
Andrej
Antworten (1)
Image Analyst
am 12 Mär. 2013
Hint, create a variable called sinx that will be the sum of all the terms. Then sum the individual terms into it in a loop. Use factorial(n).
x = 1.234; % Whatever...
sinx = 0;
for k = 1 to 100
sinx = sinx + x^ ...... % Use k and factorial(k).
end
fprintf('The value of sin(%f) = %f', x, sinx);
2 Kommentare
Siehe auch
Kategorien
Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!