Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How can I construct sparse Smolyak index matrix in Matlab?

조회 수: 1 (최근 30일)
Jaime De La Mota Sanchis
Jaime De La Mota Sanchis 2019년 9월 12일
마감: MATLAB Answer Bot 2021년 8월 20일
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개)

제품

Community Treasure Hunt

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

Start Hunting!

Translated by