Is there any way that you can make the output of the forloop into a vector you c
ID: 3811703 • Letter: I
Question
Is there any way that you can make the output of the forloop into a vector you can use in y and z??? Thank you!
******** I am trying to calculate the root mean square average and the harmonic mean for a set of data. I would like the user to input a desired number of data in their sample, for the user to enter the data, and then for the program to spit out the above values. *****************
n=input('How many values will you been inputing? --> ');
m=zeros(1:n);
for m=1:n
ii=input('Please input a value for x! --> ');
for ii= isreal
x=(1:n);
end
end
y=rms(x);
z=harmmean(x);
fprintf('The Root mean square is %f! ',y);
fprintf('The Harmonic Mean is %f! ',z);
Explanation / Answer
n=input('How many values will you been inputing? --> ');
m=zeros(1:n);
for m=1:n
x(m)=input('Please input a value for x! --> ');
end
y=rms(x);
z=harmmean(x);
fprintf('The Root mean square is %f! ',y);
fprintf('The Harmonic Mean is %f! ',z);
OUTPUT:
How many values will you been inputing? --> 5
Please input a value for x! --> 1
Please input a value for x! --> 2
Please input a value for x! --> 3
Please input a value for x! --> 6
Please input a value for x! --> 7
The Root mean square is 4.449719!
The Harmonic Mean is 2.333333!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.