Question:
I am having trouble finding the approximation for sin(x) using matlab program can someone help me?
wenskya
2011-09-14 15:58:46 UTC
This is what I've done so far, but matlab keeps giving me an error and I cannot find it. I've spent 30 minutes trying to figure it out. Can someone help me out?
function ssum=sinser(x,tol,n)
%sinser evaluate the series representation of the sine function
%
% Input: x=argument of the sine function, i.e., compute sin(x)
% tol=tolerance on accumulated sum. Default: tol=5e-9
%n=maximum number of terms. Default: n=15
%
% Output: ssum= value of series sum after nterms or tolerance is met
term=x; ssum=term; % Initialize series
fprint('series approximation to sin(%f)\n\n k term ssum\n',x);
fprint('%3d %11.3e %12.8f\n',1,term,ssum);
for k=3:2:(2*n-1)
term=-term*x*x/(k*(k-1)); % Next term in the series
ssum=ssum+term;
fprint('%3d %11.3e %12.8f\n',k,term,ssum);
if abs(term/ssum)end
fprintf('\nTruncation error after %d terms is %g\n\n',(k+1)/2,abs(ssum-sin(x)));
ssum=sinser(pi/6, 5e-9,15);
Three answers:
John
2011-09-14 16:16:06 UTC
I think you might need to be using printf instead of fprint. I'm not aware that fprint is a Matlab function but printf is.
?
2016-11-08 13:25:43 UTC
properly my daughter is likewise 3, yet we'er shorter human beings in my relatives so she is easily 3 and a nil.5 this month and is only setting up properly into her 3T denims. I even have one rule with shorts/skirts she must be waiting to hold her hand/palms flat at her aspects and the hem will nonetheless attain below her finger guidance. tank tops are nice in the summer season. i do think of that gown you published isn't little or no girlish. yet there are deffinately worse issues obtainable.. and that i word the older the girl gets the extra severe the outfits gets. with the aid of the way i'm getting alot of my outfits at objective and that i offered all of her wintry climate denims and pj's at costco this 3 hundred and sixty 5 days.
2011-09-14 17:39:36 UTC
Maybe this example on sine series (with Matlab) is helpful for you.

http://matrixlab-examples.com/sine-series.html



Maybe.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...