Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

HELLO PLEASE COULD HELP ME HOW TO CONVERT THIS CODE TO MATLAB.

1 Ansicht (letzte 30 Tage)
RUBEN NAHUE
RUBEN NAHUE am 8 Jun. 2019
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
function[L1;L2;U1;U2] = Cholesky(a; b; c)
n = length(a);
Diagonales = zeros(1; n);
Sub = zeros(1; n - 1);
if a(1) > 0 then
Diagonales(1) = sqrt(a(1));
Sub(1) = b(1)/Diagonales(1);
k = 2;
fin = 0;
while k <= n ^ fin == 0 do
if a(k) - Sub(k - 1)^2 > 0 then
Diagonales(k) = sqrt(a(k) - Sub(k -1)^2);
if Diagonales(k) = 0 ^ k < n then
Sub(k) = b(k)/Diagonales(k);
else if Diagonales(k) == 0 then
fprintf('Division por cero')
fin = 1;
end if
else
fprintf('Division por cero')
fin = 1;
end if
k = k + 1
end while
fprintf('Valor negativo en la posicion (1), no se puede ejecutar el metodo')
end if
  1 Kommentar
Walter Roberson
Walter Roberson am 8 Jun. 2019
Which language is that? It looks sort of like Maple but it is not Maple.

Antworten (1)

Walter Roberson
Walter Roberson am 8 Jun. 2019
Bearbeitet: Walter Roberson am 8 Jun. 2019
function [L1, L2, U1, U2] = Cholesky(a, b, c)
n = length(a);
Diagonales = zeros(1, n);
Sub = zeros(1, n - 1);
if a(1) > 0
Diagonales(1) = sqrt(a(1));
Sub(1) = b(1)/Diagonales(1);
k = 2;
fin = 0;
while k <= n && fin == 0
if a(k) - Sub(k - 1)^2 > 0
Diagonales(k) = sqrt(a(k) - Sub(k -1)^2);
if Diagonales(k) = 0 && k < n
Sub(k) = b(k)/Diagonales(k);
elseif Diagonales(k) == 0
fprintf('Division por cero')
fin = 1;
else
fprintf('Division por cero')
fin = 1;
end
end
k = k + 1
end
fprintf('Valor negativo en la posicion (1), no se puede ejecutar el metodo')
end
I believe the code you posted is incorrect. I think it should have an else before the final fprintf() call. Furthermore it does not calculate L1, L2, U1, or U2 that are needed for outputs.

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by