This comes from the Matlab book and I'm having the hardest time understanding it.
Chapter 5, problem 35
Vectorize this code:
n = 3;
x = zeros(n);
y = x;
for i = 1:n
x(:,i) = i;
y(i,:) = i;
end
Please help!

 採用された回答

lvn
lvn 2014 年 4 月 15 日
編集済み: lvn 2014 年 4 月 15 日

1 投票

n=3;
x=meshgrid(1:n,1:n);
y=x';

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 4 月 15 日
編集済み: Azzi Abdelmalek 2014 年 4 月 15 日

0 投票

Use repmat function

カテゴリ

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

質問済み:

2014 年 4 月 15 日

編集済み:

Jan
2014 年 4 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by