creating matrix by iteration 2

조회 수: 2 (최근 30일)
Akmyrat
Akmyrat 2014년 8월 9일
댓글: Jan 2014년 8월 10일
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
Akmyrat
Akmyrat 2014년 8월 9일
not home work :) Azzi it is more important than homework...it is part of my Final Project,..:)
Jan
Jan 2014년 8월 10일
@Akmyrat: This is a final project? And you solve it by asking a public forum? Impressing.

댓글을 달려면 로그인하십시오.

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 8월 9일
v=1:4;
a=3;
out=sort([v a])

추가 답변 (1개)

Roger Stafford
Roger Stafford 2014년 8월 9일
A = floor((15:8:47)'/10);

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by