MATLAB: How to write m file homeworkm-file I need help writing a m file function. Any pointers would be great. Thank you. Best Answer There are so many ways to do this. Probably the easiest way for a beginner is the for loop way. Hint:for tIndex = 1 : length(t) theSum = a(1); for k = 2 : length(a)-1 theSum = theSum + a(k) * cos((k-1)*t(tIndex)) + b(k) * sin((k-1)*t(tIndex)); end y(tIndex) = %%%%%%%%%%% You have to do something to finish your homeworkendSince it's your homework I probably did too much for you, but I didn't do it 100% so at least you can claim some small part as your own. Related SolutionsMATLAB: Frequency components from a highpass filtered image Take the Fourier Transform of it. MATLAB: How to display only the last iteration Move the fprintf to after the loop:theSum = 0;for k = 1:numel(x); theSum = theSum + x(k);endfprintf('The total value of x is %.1f, and the average value of x is %.3f\n\n',...,theSum, theSum/k); Related QuestionHow to find sum of square sine waveHow to calculate this sym of serieFind the sum of the non perimeter elements of a matrix using a for loop
Best Answer