Why do I get this error?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Tianlan Yang
am 18 Mär. 2021
Bearbeitet: Adam Danz
am 19 Mär. 2021
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/555233/image.png)
Here is the function:
function [X1,X2,X] = msystem(A,B)
[~,n] = size(A);
[~,p] = size(B);
[L,U] = lu(A);
%solving for X1
X1 = inv(A)*B;
invL = [L eye(n)];
invL = rref(invL);
invL = invL(:,(n+1:n*2));
Y = invL*B;
invU = [U eye(n)];
invU = rref(invU);
invU = invU(:,(n+1:n*2));
X2 = invU * Y;
X = Y ./ U;
if (closetozeroroundoff(X1 - X2) == zeros(n,p))
disp('The solutions are the same')
else
disp('An error has been made on this exercise')
end
if (closetozeroroundoff(X1 - X) == zeros(n,p))
disp('The solutions are the same')
else
disp('An error has been made on this exercise')
end
end
0 Kommentare
Akzeptierte Antwort
Adam Danz
am 18 Mär. 2021
Bearbeitet: Adam Danz
am 18 Mär. 2021
closetozeroroundoff(), a 3rd party function not defined in the question, contains more than one input and one of the inputs is apparently named H or p. However, you're only providing 1 input so H or p is not defined in the function.
11 Kommentare
Adam Danz
am 19 Mär. 2021
Bearbeitet: Adam Danz
am 19 Mär. 2021
That's like asking how to make this cube look like a circle. A 4x3 matrix can never look like a 3x3 matrix without changing the data. You can remove the first row, second row, third row, or 4th row of the 4x3 matrix but now it's a completely different variable.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/555937/image.jpeg)
m = (1:4)'.*ones(1,3)
m(3,:) = [] % remove 3rd row
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!