A problem including an array

I'm a C++ programmer, but never worked with MATLAB before, I have a problem to solve but I don't know the syntax very well. So, here is the problem: I have to input an array A(6,6) from the keyboard. If the result of multiplication of the elements in the main diagonal is greater than the sum of the smallest and the biggest element in the array, to calculate the function graphically: y = (A(3,1)/sqrt(3)A(2,2))*x^2+A(2,4)*x-8 for x is element of [-3:3] and delta x = 0.25. It is really easy to do that on C and C++ but I have a real hard time doing it on MATLAB. I would be really grateful if someone help me out. Thank you!

 채택된 답변

Roger Stafford
Roger Stafford 2013년 5월 27일

0 개 추천

if prod(diag(A)) > min(A(:)) + max(A(:))
x = [-3:.25:3]; % or linspace(-3,3,25)
y = A(3,1)/sqrt(3)*A(2,2)*x.^2 + A(2,4)*x - 8;
plot(x,y)
else
% Whatever is to happen if the test fails
end
(I assume A(2,2) is to be in the numerator in your notation.)

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by