How do can I use every number in my loop?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Dameon Solestro
am 24 Nov. 2021
Beantwortet: Walter Roberson
am 24 Nov. 2021
So right now I have 3 groups of 5 x values(15 x values in total. How do I perform a loop where I use the values after I get the mean?? so how would i create a matrix such that . M= [x1-Mean_allx ; x2-Mean_allx ; x3-Mean_allx ;...... ; x15-Mean_allx] ?? Could it also be possible for the value to be Matrix to be averaged?
for j=1:3
for i=1:5
x(i,j)= rand()
hold on
end
hold on
h(j)=mean(x(:,j))
Mean_allx= mean(h)
end
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 24 Nov. 2021
for j=1:3
for i=1:5
x(i,j)= rand()
end
h(j)=mean(x(:,j))
end
Mean_allx= mean(h)
0 Kommentare
Weitere Antworten (1)
the cyclist
am 24 Nov. 2021
Bearbeitet: the cyclist
am 24 Nov. 2021
% Set the random number seed, for reproducibility
rng default
% Create the x data
x = rand(3,5);
% Mean of all the x data
Mean_allx = mean(x,'all');
% Subtract the mean from the x data
x_minus_mean = x - Mean_allx;
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!