MATLAB: A*x = b with maximal x

ax=bmaximation

Hey guys, I am struggling with a rather easy mathematical problem:
I have a 3×2 Matrix, U = A\b gives me a solution with the minimal norm(U). But I want to have the maximum, where U(1,2,3) < 24000. Do you have an idea? Here is my code so far:
alpha = 12.34567;
dU = 1;
beta = [0 120 240];
A = [sind(beta(1)) sind(beta(2)) sind(beta(3)); cosd(beta(1)) cosd(beta(2)) cosd(beta(3))];
b = [tand(alpha) 1]';
% Rang = rank(A)
%
U = A\b

Best Answer

I found a solution, but it's not giving the right answers...
Startwert = [1,1,1];
[Uopt,UZeiger] = fmincon(@(U) Ufunktion(U),Startwert,[],[],[],[],[],[],@(U) Nebenbed(U,UZeiger,Umax,alpha,beta),optimset('Display','off','Algorithm','active-set'));
UZeiger = -UZeiger;
% Lösung mit Numerischer Methodik
function[UZeiger] = Ufunktion(U)
UZeiger = sum(U);
end
% Analog werden die Nebenbedingungen als Funktion definiert
function[c,ceq] = Nebenbed(U,UZeiger,Umax,alpha,beta)
% die Gleichungsnebenbedingungen
ceq = [sind(beta(1))*U(1) + sind(beta(2))*U(2) + sind(beta(3))*U(3) - tand(alpha);
cosd(beta(1))*U(1) + cosd(beta(2))*U(2) + cosd(beta(3))*U(3) - 1;
];
% die Ungleichungsnebenbedingungen
c = UZeiger - 3*Umax; % U(2) - 24000;U(3) - 24000; % Maximalwerte der Spannung
end