input the matrix from user

3 vues (au cours des 30 derniers jours)
Muhammad
Muhammad le 19 Août 2021
Modifié(e) : Jan le 19 Août 2021
i want to find out the mean of the matrix
but the matix should be given by users in command window
y= input(a);
% mean(mean(A,1),2);

Réponse acceptée

Jan
Jan le 19 Août 2021
Modifié(e) : Jan le 19 Août 2021
A = input('Please input the matrix like "[1, 2; 3, 4]":');
% Type e.g.:
% [1, 2; 3, 4]
meanA = mean(A(:))
% Or in modern Matlab versions:
meanA = mean(A, 'all')
% Or more basic:
meanA = sum(A, 'all') / numel(A)
See:
doc input

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by