How to Plot a 4th Degree Polynomial in MATLAB: Step-by-Step Guide

Click For Summary

Discussion Overview

The discussion revolves around plotting a fourth degree polynomial in MATLAB, focusing on the necessary coding techniques and potential misunderstandings regarding terminology and syntax. Participants share their insights on how to properly implement the equation in MATLAB and clarify common pitfalls for beginners.

Discussion Character

  • Technical explanation
  • Conceptual clarification
  • Debate/contested

Main Points Raised

  • One participant requests guidance on plotting a fourth degree polynomial equation in MATLAB.
  • Another participant explains the need for element-wise operations in MATLAB, suggesting the use of the dot operator for exponentiation when dealing with matrices.
  • It is noted that the dot operator is often overlooked by beginners in MATLAB.
  • Some participants express confusion over the terminology "Grade 4," clarifying that "fourth degree" is the correct term in English.
  • There is a suggestion that the original poster may simply want to graph the equation for real number values of x.
  • A participant provides a basic example of plotting in MATLAB, demonstrating how to create vectors for x and y values.
  • Another participant mentions an alternative software, Freemat, which offers similar functionality to MATLAB.

Areas of Agreement / Disagreement

Participants generally agree on the need for element-wise operations in MATLAB, but there is some disagreement regarding the terminology used to describe the polynomial degree. The discussion remains unresolved regarding the original poster's intent and understanding.

Contextual Notes

There are indications of confusion regarding terminology and syntax, particularly for those new to MATLAB. The discussion does not resolve whether the original poster's equation was intended for a specific context or audience.

saeede-
Messages
8
Reaction score
0
hey everyone . I want to plot a Grade 4 equation in MATLAB. but don't know how to do. Can anyone guide me?

equation : f = 1.47*(x^4)-10^7*(x)+58.92*(10^6)
 
Physics news on Phys.org
If your x is a row/column matrix you will need to add a . before multiplicative operations to make them element-by-element. In other words, if you have something like
Code:
x = 0:0.01:10;
then you will need to do
Code:
f = 1.47*(x.^4)-10^7*(x)+58.92*(10^6)
because Matlab does not understand what a row/column matrix to the power of 4 means.
 
  • Like
  • Love
Likes   Reactions: jedishrfu and saeede-
The dot operator is something often missed by newbies to matlab.
 
saeede- said:
hey everyone . I want to plot a Grade 4 equation in MATLAB. but don't know how to do. Can anyone guide me?

equation : f = 1.47*(x^4)-10^7*(x)+58.92*(10^6)
Your post confused me -- I thought this might be an equation given to someone in the fourth grade. In English we call such equations fourth degree, not Grade 4.
 
Orodruin said:
If your x is a row/column matrix you will need to add a . before multiplicative operations to make them element-by-element.
I suspect, without much evidence, that the OP merely wants to graph the equation, where x is a real number.
 
Mark44 said:
I suspect, without much evidence, that the OP merely wants to graph the equation, where x is a real number.
Yes, and the typical way to do that in MATLAB is to first create a vector x containing the x values, then using a function as described above to get the corresponding y-values. Then using the MATLAB plot function, which takes the vectors of x and y values as input. This is why you need the dot in the operator in the second step.
 
  • Like
Likes   Reactions: jedishrfu
[CODE lang="matlab" title="Plot example"]x = [0:100]
y = x .* x
plot(x,y)[/CODE]

Also there is a nice MATLAB clone called Freemat which supports the core functionality of MATLAB.

http://freemat.sourceforge.net/
 
  • Like
  • Informative
Likes   Reactions: PhDeezNutz, berkeman and Orodruin
Mark44 said:
Your post confused me -- I thought this might be an equation given to someone in the fourth grade. In English we call such equations fourth degree, not Grade 4.
yes :)) I'm not an English person . so it's normal having such mistakes.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
Replies
2
Views
3K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 6 ·
Replies
6
Views
4K