Performs the generalized app
Afficher commentaires plus anciens
Please help to generalized the program for given n and input data read from a Excel file Aleator.xlsx with n=1024 or the general case n read as input or set from the begining?
D = xlsread('Aleat.xlsx',1);
n = 11;
nCols = 11
a11 = 0; a21 = 0 ; a31 = 0; a41 = 0; a51 = 0; a61 =0; a71=0; a81=0; a91=0; a101=0;
M = zeros(n,n);
M(1,1:n) = 0;
DM = zeros(10,10);
for i = 1:n
DM(i,1) = D(i,1)-D(i+1,1);
end;
for i = 1:(n-1)
DM(i,2) = DM(i,1)-DM(i+1,1);
end;
for i = 1:(n-2)
DM(i,3) = DM(i,2)-DM(i+1,2);
end;
for i = 1:(n-3)
DM(i,4) = DM(i,3)-DM(i+1,3);
end;
for i = 1:(n-4)
DM(i,5) = DM(i,4)-DM(i+1,4);
end;
for i = 1:(n-5)
DM(i,6) = DM(i,5)-DM(i+1,5);
end;
for i = 1:(n-6)
DM(i,7) = DM(i,6)-DM(i+1,6);
end;
for i = 1:(n-7)
DM(i,8) = DM(i,7)-DM(i+1,7);
end;
for i = 1:(n-8)
DM(i,9) = DM(i,8)-DM(i+1,8);
end;
for i = 1:(n-9)
DM(i,10) = DM(i,9)-DM(i+1,9);
end;
for i = 1:(n-10)
DM(i,11) = DM(i,10)-DM(i+1,10);
end;
b1 = D(14,1); .....b11 = D(4,1);
B1 = [b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11];
B2 = B1'
if size(DM, 1) < nCols
error('Insufficient number of equations.');
end
a = DM' \ B1';
X = linsolve(DM, B1');
a11 = a(1,1); a21 = a(2,1); a31 = a(3,1); a41 = a(4,1); a51 = a(5,1); a61 = a(6,1); a71 = a(7,1); a81 = a(8,1); a91 = a(9,1); a101 = a(10,1);
b1 = DM(1,1)*a11+DM(1,2)*a21+DM(1,3)*a31+DM(1,4)*a41+DM(1,5)*a51+DM(1,6)*a61+DM(1,7)*a71+DM(1,8)*a81+DM(1,9)*a91+DM(1,10)*a101;
b2 = ....
b10 = DM(10,1)*a11+DM(10,2)*a21+DM(10,3)*a31+DM(10,4)*a41+DM(10,5)*a51+DM(10,6)*a61+DM(10,7)*a71+DM(10,8)*a81+DM(10,9)*a91+DM(10,10)*a101;
a = DM' \ B1';
X = linsolve(DM, B1');
disp(a);
disp(X);
To read from a Excel file Aleator.xlsx with n=1024 or the general case n read as input or set from the begining?
1 commentaire
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Categorical Arrays dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!