How to extract array from the mean directly using indexing?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
William
am 6 Jul. 2023
Bearbeitet: Nikhil Baishkiyar
am 6 Jul. 2023
A = [2.29441228002842 17.3351873969651 2.79928860040389 7.17554281085515;
3.16200415659481 16.9975006219209 3.18395042061777 7.45747601536461;
4.55387378846938 13.4948344868957 3.22594708715312 7.49001605579868]
meanA = mean(A,1)
output: [3.3368 15.9425 3.0697 7.3743]
how can i get second element of mean in one line?
ex:
mean(A,1)(2)
- (2) is index
But, it is not working. Thanks.
0 Kommentare
Akzeptierte Antwort
Nikhil Baishkiyar
am 6 Jul. 2023
Bearbeitet: Nikhil Baishkiyar
am 6 Jul. 2023
A = [2.29441228002842 17.3351873969651 2.79928860040389 7.17554281085515;
3.16200415659481 16.9975006219209 3.18395042061777 7.45747601536461;
4.55387378846938 13.4948344868957 3.22594708715312 7.49001605579868]
mean(A(:,2))
You mean something like this?
subindex = @(matrix, r) matrix(r); % An anonymous function for indexing
value = subindex(mean(A,1), 2) % Use the function to index the vector
3 Kommentare
Nikhil Baishkiyar
am 6 Jul. 2023
Bearbeitet: Nikhil Baishkiyar
am 6 Jul. 2023
I read the post and updated my answer based on that. If you want every mean value you will have to store it in a temporary variable I am afraid
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!