MATLAB Answers

How can I construct sparse Smolyak index matrix in Matlab?

Good morning-afternoon.
I need to construc a matrix defined by two variables. The first, d is the dimensions and the second, l, is the level. The matrix has as many columns as the value of d. The elements of the rows are defined as follows: I_{d<=|i|<=d+l}. This means that the elements of each row have to add a number between d and d+l, both included. An example would be as follows: d=3, l=1. I=[1 1 1; 2 1 1; 1 2 1; 1 1 2]
Another example would be d=2 l=2. I=[1 1; 2 1; 1 2; 3 1; 2 2; 1 3]
I have developed a piece of code that works for all values of d, but fails for values of l of two or higher. It is as follows:
close all
clear
clc
contador=1;
number_of_rv=3; %This is d; l is 1 in this case.
mat_index = ones(number_of_rv+1, number_of_rv);
mat_ampl = zeros(2*number_of_rv+1, number_of_rv);
longitud_mat_ampl=length(mat_ampl);
mat_aux=zeros(2);
for i=2: number_of_rv+1
mat_index(i,contador)=2;
contador=contador+1;
end
Any help is appreciated.
Thanks.
Jaime.

  댓글 수: 0

로그인 to comment.

제품

답변 수: 0


Translated by