creating matrix by iteration 2

2 vues (au cours des 30 derniers jours)
Akmyrat
Akmyrat le 9 Août 2014
Commenté : Jan le 10 Août 2014
Hi Everyone how are You? Can U help with this PLEASE: n=4 for i=1:n s=i if s == 3 for k =1:2 A(i,1) =s A(s+1,1)=s end else A(i,1) =s end end I want like this result: A=[1;2;3;3;4]. which if s == 3 it should be repeated 2 times in the matrix.
  5 commentaires
Akmyrat
Akmyrat le 9 Août 2014
not home work :) Azzi it is more important than homework...it is part of my Final Project,..:)
Jan
Jan le 10 Août 2014
@Akmyrat: This is a final project? And you solve it by asking a public forum? Impressing.

Connectez-vous pour commenter.

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 9 Août 2014
v=1:4;
a=3;
out=sort([v a])

Plus de réponses (1)

Roger Stafford
Roger Stafford le 9 Août 2014
A = floor((15:8:47)'/10);

Catégories

En savoir plus sur Creating and Concatenating Matrices 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