MATLAB Script Help - Plotting 2 Functions to Find Intersection

  • Context: MATLAB 
  • Thread starter Thread starter MMCS
  • Start date Start date
  • Tags Tags
    Matlab
Click For Summary
SUMMARY

The forum discussion focuses on a MATLAB script aimed at plotting two functions to determine their intersection points. The user encountered an issue where the graph displayed only points instead of the expected functions. Key insights include the necessity of varying the variable 'w' in the script to generate continuous plots and the suggestion to utilize the 'fzero()' function to find the intersection of the functions defined as m = tanh(m).

PREREQUISITES
  • Familiarity with MATLAB scripting and syntax
  • Understanding of function plotting in MATLAB
  • Knowledge of the hyperbolic tangent function (tanh)
  • Experience with numerical methods, specifically root-finding techniques like fzero()
NEXT STEPS
  • Learn how to implement variable iteration in MATLAB scripts
  • Explore the use of the fzero() function for finding roots of equations
  • Study the properties and applications of the hyperbolic tangent function
  • Investigate advanced plotting techniques in MATLAB for better visualization
USEFUL FOR

This discussion is beneficial for MATLAB users, particularly those involved in mathematical modeling, numerical analysis, and anyone seeking to improve their skills in function plotting and intersection analysis.

MMCS
Messages
151
Reaction score
0
Attahced is my short MATLAB script, I am basically trying to use iteration to plot 2 sets of 2 functions to see where they intersect, all other information in the script are constants. attached also is the incorrect graph that i get

flux = F

If = Ifield

Any help would be appreciated
 

Attachments

  • matlab.jpg
    matlab.jpg
    19.1 KB · Views: 533
Physics news on Phys.org
You plotted a few points instead of each function.

The way you've defined everything, there are no variables. Everything is a constant, which is why you only get points. Should you be varying w to plot each function?

Also, if you just want to know where the two functions of the form m = tanh(m) intersect, you can also plot m-tanh(m) and use fzero() to find the zero where they are equal.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 14 ·
Replies
14
Views
4K
Replies
4
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 9 ·
Replies
9
Views
5K