How to create a matrix B=[bij]=[max(i,j)] belongs to class of rectangular matrices

3 vues (au cours des 30 derniers jours)
Please answer me

Réponse acceptée

Birdman
Birdman le 9 Fév 2018
One way is symbolical:
i=3;j=4;
B=sym('B',[i j])
  2 commentaires
Farooq Aamir
Farooq Aamir le 9 Fév 2018
Thanks birdman but how i get without symbolic
Birdman
Birdman le 9 Fév 2018
i=3;j=4;B=string(zeros(i,j));
for a=1:i
for b=1:j
B(a,b)=sprintf('b%i%i',a,b);
end
end

Connectez-vous pour commenter.

Plus de réponses (1)

Christine Tobler
Christine Tobler le 12 Fév 2018
Focusing on the max(i, j) part, you could use
i = 3;
j = 4;
B = max((1:i)', (1:j));

Community Treasure Hunt

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

Start Hunting!

Translated by