Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
How can I construct sparse Smolyak index matrix in Matlab?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (0)
Diese Frage ist geschlossen.
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!