Matlab help
Need help, this mini program is pissing me off...
Can you post it? (And is it a math problem, or Computer Science?)
matlab and I just figured it out.
%% Problem 9.1 %{ Use a for loop to sum the elements in the following vector: x = [1, 23, 43, 72, 87, 56, 98, 33] %} % vectors given in problems, assign new variable c9p1 = [1, 23, 43, 72, 87, 56, 98, 33]; sum = 0; for k = 1:length(c9p1) sum = sum + c9p1(k); end disp('The sum of c9p1 is: %f', sum); shy doesn't disp work like this?
@mjdennis
never mind I am using fprintf() it's better, less coding.
Yeah, if I remember 'disp' correctly, you can do disp('words') or disp(variable), but i'm not sure it does both at once. And disp definitely doesn't use %f formatting. In fact, the 'f' in 'fprint' stands for 'formatted print'. Glad you got it!
Join our real-time social learning platform and learn together with your friends!