
Math Software Math Software  Mathematica, Matlab, Calculators, Graphing Software 
 LinkBack  Thread Tools  Display Modes 
December 21st, 2016, 05:32 AM  #1 
Newbie Joined: Dec 2016 From: Netherlands Posts: 15 Thanks: 0  Using Matlab
I have never used Matlab before, now i came across this problem:Take the values a1 = 1.0, a2 = 0.5, b1 = 0.1 and b2 = 0.002 and draw (in the phase plane) the curve given by (3) for the initial values p(0) = 100 and r(0) = 20. You can use the following function % contourplot draws curves given implicitly % contourplot(f, a, b, c, d, N) draws the curve implicitly % given by f(x,y) = 0 where f is a function % in x and y in the rectangle a < x < b, c < y < d % The parameter N determines the smoothness of the plotted curve % Example: Type these lines in the Matlab command window % f = @(x,y) sin(x + 2*y.^2); % contourplot(f, 3, 3, 4, 4, 50); function z = contourplot(f, a, b, c, d, N) [x,y] = meshgrid(a : (ba)/N:b, c : (dc)/N:d); z = f(x,y); contour(x, y, z, [0 0]); axis square To use this function, take the following steps: • Create a new script in the Matlab editor • Copy and paste the Matlab script listed here into the Matlab editor • Save the script under the name contourplot.m You have now added a function to Matlab and you can call the contourplot function from your own scripts and from the command window just like any other builtin Matlab command. (the formula to use(3) is:a2 ln p − b2 p + a1 ln r − b1r = constant. i have added the contourplot as stated but i dont know how to put the formula in matlab, anyone that can help? 
December 21st, 2016, 10:06 AM  #2 
Senior Member Joined: Sep 2016 From: USA Posts: 377 Thanks: 205 Math Focus: Dynamical systems, analytic function theory, numerics 
It seems you want a level curve of the form: $a_2 \ln p − b_2 p + a_1 \ln r − b_1r = c$ where $a_1,a_2,b_1,b_2,c$ are each fixed constants. So your variables are $p,r$. Is this correct? If so this corresponds to the level curve at 0 for $f(p,r) = a_2 \ln p − b_2 p + a_1 \ln r − b_1r  c$. This is coded in matlab as an anonymous function (similar to a "lambda" function in python) using the following code which you can copy/paste and replace each ? with the value of the constant for your problem. a1 = ?; a2 = ?; b1 = ?; b2 = ?; c = ?; f = @(p,r)(a2.*log(p)  b2.*p + a1.*log(r)  b1.*r  c); 

Tags 
matlab 
Thread Tools  
Display Modes  

Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Matlab Help  bigacougar22  Computer Science  0  July 28th, 2015 05:03 PM 
Matlab help  WWRtelescoping  Math Software  1  March 3rd, 2015 12:07 PM 
matlab  Prakhar  Math Software  1  August 20th, 2014 01:47 AM 
Need Matlab Help  stealth4933  Math Software  1  April 30th, 2014 02:37 AM 
Matlab Help!  Abhimint  Math Software  0  January 26th, 2013 06:47 PM 