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 件のコメント

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 8 月 9 日
Format correctly your code
Akmyrat
Akmyrat 2014 年 8 月 9 日
Ok let my try to explain...lets say iteration from i=1:4, i want to create like this matrix from this iteration, if a=2, i want number 2 appear twice in that matrix, C=[1 2 2 3 4], or example if a=3, number 3 should appear twice, C=[1 2 3 3 4]
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 8 月 9 日
Is this a homework?
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 日

0 投票

v=1:4;
a=3;
out=sort([v a])

その他の回答 (1 件)

Roger Stafford
Roger Stafford 2014 年 8 月 9 日

1 投票

A = floor((15:8:47)'/10);

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

質問済み:

2014 年 8 月 9 日

コメント済み:

Jan
2014 年 8 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by