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