MATLAB: How can i create in script y=cos(x), between (0,2*pi) linspace(0,1,n) and the angel is 10degrees using for (loop) and Disp and SprintF

student

help 🙁

Best Answer

%sinefun3.m n=21; x=linspace(0,1,n); %x=2*pi*linspace(0,1,n); y=sin(2*pi*x); %y=sin(x); disp('hi ') disp(' k x(k) sin(x(k))') for k=1:n degrees = (k-1)*360/(n-1); disp(sprintf('%2.0f %3.0f %6.3f ',... k ,degrees,y(k))) end disp(' ') disp(sprintf('one Degree = %5.3e Radians ',... pi/180))
Related Question