input the matrix from user

4 次查看(过去 30 天)
Muhammad
Muhammad 2021-8-19
编辑: Jan 2021-8-19
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);

采纳的回答

Jan
Jan 2021-8-19
编辑:Jan 2021-8-19
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by