필터 지우기
필터 지우기

I created a zeros (n+1 by n+1) matrix. And I want the value 2*i on the row (2 : n)&(column 1:n-1) , where i is from 1 to n-1, how should I get that? Can anyone help me out?

조회 수: 1 (최근 30일)
I tried this :
n=4;
A=zeros(n+1);
for i=2:n-1
A([2:n,2:n-1])=[2*i]
end
But it didnt work
  댓글 수: 2
Roger Stafford
Roger Stafford 2017년 4월 19일
편집: Roger Stafford 2017년 4월 19일
Your statement isn’t clear to me. Could you give a specific example of what you want A to be with, say, n = 4.
kingsley
kingsley 2017년 4월 19일
편집: kingsley 2017년 4월 19일
Hi, Roger. The attachment is the example of A. And the xi is from 1 to n-1

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

채택된 답변

Andrei Bobrov
Andrei Bobrov 2017년 4월 19일
n = 4;
A = zeros(n);
A(2:n+1:end) = 2*(1:n-1);
A(n+1,n+1) = 0;

추가 답변 (1개)

KSSV
KSSV 2017년 4월 19일
n = 4 ;
A = zeros(n+1) ;
A(2:n,1:n-1) = repmat(2*(1:n-1),n-1,1) ;
  댓글 수: 1
kingsley
kingsley 2017년 4월 19일
편집: kingsley 2017년 4월 19일
Hi, KSSV. First of all, thanks for your effort! I might not be very clear on the requirement of the matrix. The attachment is the required matrix I need to make. And the xi is from 1 to n-1 Thanks !!!!

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

카테고리

Help CenterFile Exchange에서 Search Path에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by