Q:

A program has a vector of structures that stores information on experimental data that has been collected. For each experiment, up to 10 data values were obtained

0

A program has a vector of structures that stores information on experimental data that has been collected. For each experiment, up to 10 data values were obtained. Each structure stores the number of data values for that experiment, and then the data values. The program is to calculate and print the average value for each experiment. Write a script to create some data in this format and print the averages.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Ch14Ex12.m

% create data structure

exper(3).numvals = 5;

exper(3).vals = 1:5;

exper(1).numvals = 1;

exper(1).vals = 33;

exper(2).numvals = 10;

exper(2).vals = [3:5 1.1:0.1:1.5 11];

for i = 1:length(exper)

 fprintf('The average value for experiment %d',i)

 fprintf(' was %.2f\n', mean(exper(i).vals))

end

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now