How to create a matrix out from the output of a formula... I am trying to find the ave of the data entered but it just stores the final ave computed from a list of data, im trying to create a loop that will store the results in a matrix s

1 view (last 30 days)
function [] = reportGraph(data, scores, stats)
% print report and draw graph
% print table
fprintf('2020 AU Softball Batting Stats as of 03/01\n')
fprintf('Date Scores W/L AB Runs Hits HRuns Ave\n')
for i=1:(data)
ave=stats(3,i)/stats(1,i);
i=i+1;
end
disp (ave)
for x= 1:length(data)
if scores(1,x) > scores(2,x)
fprintf('%02.0f/%02.0f %02.0f-%02.0f W %2.0f %2.0f %2.0f %2.0f %5.3f\n', data(:,x),scores(:,x), stats(:,x),i)
else
fprintf('%02.0f/%02.0f %02.0f-%02.0f L %2.0f %2.0f %2.0f %2.0f %5.3f\n', data(:,x),scores(:,x), stats(:,x),i)
end
end
scoreAuAve = mean(scores(:,1));
scoreOpAve = mean(scores(:,2));
abAve = mean(stats(1,:));
runsAve = mean(stats(2,:));
hitsAve = mean(stats(3,:));
hrunsAve = mean(stats(4,:));
aveAve = mean(i(:));
fprintf('Ave: %03.1f-%03.1f %4.1f %3.1f %3.1f %3.1f %5.3f\n', scoreAuAve,scoreOpAve,abAve,runsAve,hitsAve,hrunsAve,aveAve)
plotGraph(scores)
end
  5 Comments
Jaxon Cowles
Jaxon Cowles on 1 Apr 2020
No, that would just give me the mean of "runsAve". Below is my output, as you see the ave is just the last reported output:
2020 AU Softball Batting Stats as of 03/01
Date Scores W/L AB Runs Hits HRuns Ave
02/07 00-08 L 14 0 2 0 0.143
02/29 05-01 W 25 5 6 0 0.240
02/29 10-03 W 27 10 8 2 0.296
03/01 11-06 W 31 11 12 1 0.387
03/01 06-00 W 27 6 11 0 0.407
Ave: 5.2-3.9 25.2 5.2 7.1 0.8 0.407

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!