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?

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 Comments

Your statement isn’t clear to me. Could you give a specific example of what you want A to be with, say, n = 4.
Hi, Roger. The attachment is the example of A. And the xi is from 1 to n-1

Sign in to comment.

 Accepted Answer

More Answers (1)

n = 4 ;
A = zeros(n+1) ;
A(2:n,1:n-1) = repmat(2*(1:n-1),n-1,1) ;

1 Comment

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 !!!!

Sign in to comment.

Categories

Find more on Mathematics in Help Center and File Exchange

Asked:

on 19 Apr 2017

Edited:

on 19 Apr 2017

Community Treasure Hunt

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

Start Hunting!