plot the polynomial y=0.7x^4-13.5x^2+6x-37 in the domain-5<x<5 in matlab

To plot the given polynomial in the specified domain, you can follow these steps:

  1. Define the polynomial function in Matlab using anonymous function syntax:
main.m
f = @(x) 0.7*x.^4 - 13.5*x.^2 + 6*x - 37;
42 chars
2 lines
  1. Generate a range of values for x within the desired domain using linspace function:
main.m
x = linspace(-5, 5);
21 chars
2 lines
  1. Evaluate the polynomial function for each value of x using element-wise operations:
main.m
y = f(x);
10 chars
2 lines
  1. Plot the polynomial using plot function:
main.m
plot(x, y);
12 chars
2 lines
  1. Add axis labels and title to the plot with the xlabel, ylabel, and title functions:
main.m
xlabel('x');
ylabel('y');
title('Polynomial Plot');
52 chars
4 lines

The final Matlab code would look like this:

main.m
% Define the polynomial function
f = @(x) 0.7*x.^4 - 13.5*x.^2 + 6*x - 37;

% Define the range of values for x
x = linspace(-5, 5);

% Evaluate the polynomial function for each value of x
y = f(x);

% Plot the polynomial
plot(x, y);

% Add axis labels and title
xlabel('x');
ylabel('y');
title('Polynomial Plot');
314 chars
17 lines

This will generate a plot of the given polynomial in the domain -5 < x < 5.

gistlibby LogSnag