Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

How can I construct sparse Smolyak index matrix in Matlab?

1 visualización (últimos 30 días)
Jaime De La Mota Sanchis
Jaime De La Mota Sanchis el 12 de Sept. de 2019
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
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.

Respuestas (0)

La pregunta está cerrada.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by