Duplicate the value of a cell for other cells in a matrix

Hello everyone,
I have a large-size matrix A with 100 rows and 1000 columns. I was wondering how I can duplicate the value of a single cell to some other cells. For example, lets assume A(2,5)=4. Then, how can I have the same value for other 1000 cells of matrix A? These 1000 cells can be of any row and column.
For this sake, my main concern is to speed up the run and avoid as loops as possible.
Any help or remark is highly appreciated! Thank you!

3 件のコメント

Matt Fig
Matt Fig 2012 年 9 月 6 日
編集済み: Matt Fig 2012 年 9 月 6 日
By the way, in MATLAB a cell array is a specific thing. If you are talking about a numerical array (a matrix for example), then they are elements, not cells.

サインインしてコメントする。

 採用された回答

Matt Fig
Matt Fig 2012 年 9 月 6 日
編集済み: Matt Fig 2012 年 9 月 6 日

0 投票

Here is an example; adapt it as needed.
A = magic(10); % The array.
N = randperm(numel(A)); % Random linear indices.
A(N(1:20)) = A(1,1); % Set 20 random elements of A to equal A(1,1).

1 件のコメント

Alireza
Alireza 2012 年 9 月 6 日
Thank you Matt for your help!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by