I want to plot when . I wrote the following codes and was wondering if there is a more efficient way with less number of lines:
clcclearQ = [0.7750, 0.3897; 0.3897 0.3250];b = [-2,-1];[X,Y] = meshgrid(-5:0.1:1);x = X(:);y = Y(:);sx = size(X);n = length(x);z = zeros(n,1);for i = 1:n z(i) = 0.5*[x(i,1),y(i,1)]*Q*[x(i,1);y(i,1)] - b*[x(i,1);y(i,1)];endX = reshape(x,sx);Y = reshape(y,sx);Z = reshape(z,sx);surf(X,Y,Z)
Best Answer