Hey,
I want to create a matrix out of one vector.
v=[1,2,3,4]
And the matrix should have the form
M= 1 2 3 4
2 2 3 4
3 3 3 4
4 4 4 4
Is there an easy solution for that?
Thanks

 채택된 답변

Voss
Voss 2022년 6월 12일

0 개 추천

v=[1,2,3,4];
N = numel(v);
idx = max(1:N,(1:N).');
M = v(idx)
M = 4×4
1 2 3 4 2 2 3 4 3 3 3 4 4 4 4 4

댓글 수: 2

Johannes Reiers
Johannes Reiers 2022년 6월 12일
Thanks a lot
Voss
Voss 2022년 6월 12일
You're welcome!

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

추가 답변 (1개)

Jan
Jan 2022년 6월 12일

0 개 추천

v = [1,2,3,4];
max(v, v.')
ans = 4×4
1 2 3 4 2 2 3 4 3 3 3 4 4 4 4 4

카테고리

도움말 센터File Exchange에서 Elementary Math에 대해 자세히 알아보기

제품

릴리스

R2022a

태그

질문:

2022년 6월 12일

댓글:

2022년 6월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by