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 Exchange에서 Resizing 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