How can i variate the index for the matrix input by the user in command window
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Code: syms('a','b','A','n') fprintf('Enter the value of n:') n=input(' '); for a=1:n; for b=1:n; A(a,b)=input(' '); end end A
Output:
Enter the value of n: 2 1 2 3 4
A =
[ 1, 2] [ 3, 4]
i want to have an interface like A(1,1)=1 A(1,2)=2
please guide me as soon as possible
0 Commenti
Risposte (1)
Paulo Silva
il 2 Mar 2011
n=input('Please input the size (n) of the matrix:');
A=zeros(n,n)
for idx=1:n
[row,col]=ind2sub(size(A),idx);
A(idx)=input(sprintf('A(%d,%d)=A(%d)=',row,col,idx));
end
A
0 Commenti
Vedere anche
Categorie
Scopri di più su Get Started with MATLAB in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!