MATLAB: Is it right

checkhomework

Question is here:Use MATLAB to plot the polynomials y=3×4-6×3+8×2+4x+90 and z=3×3+5×2-8x+70 over the interval -3≤x≤3. Properly label the plot and each curve. The variables y and z represent current in milliamperes; the variables x represents voltage in volts.
The code is here:
clc
clear
x=[-3:3]
y = 3*x.^4-6*x.^3+8*x.^2+4*x+90;
z = 3*x.^3+5*x.^2-8*x+70;
plot(x, y,x,z)
xlabel('Voltage(V)')
ylabel('milliamperes(A)')
if true
% code
end

Best Answer

Looks right to me. I just fancied it up a bit:
x = [-3:3]
y = 3*x.^4-6*x.^3+8*x.^2+4*x+90;
z = 3*x.^3+5*x.^2-8*x+70;
plot(x, y, 'bo-', 'LineWidth', 2)
hold on;
plot(x, z, 'rd-', 'LineWidth', 2)
grid on;
xlabel('Voltage (V)', 'FontSize', 20)
ylabel('Current in Milliamperes (mA)', 'FontSize', 20)
title('Voltage vs. Current', 'FontSize', 20)
legend('y', 'z', 'Location', 'north');
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);