I am trying to draw a contour for an equation which I got from Mathematica. I was able to draw this contour easily in mathematica but not on matlab. Kindly suggest.
b=linspace(0.0005,0.0010,100);
c=linspace(0.64,0.7,100);
z=(-136*power(2.718281828459045,power(88682,c)*b)*(1 - 1/power(2.718281828459045,1*power(88682,c)*b)))/(-1+ power(2.718281828459045,power(88682,c)*b)) - 1*(power(3,c) + power(33,c) + power(146,c) + power(227,c) + power(342,c) + power(351,c) + power(353,c) + power(444,c) + power(556,c) + power(571,c) + power(709,c) + power(759,c) + power(836,c) + power(860,c) + power(968,c) + power(1056,c) + power(1726,c) + power(1846,c) + power(1872,c) + power(1986,c) + power(2311,c) + power(2366,c) + power(2608,c) + power(2676,c) + power(3098,c) + power(3278,c) + power(3288,c) + power(4434,c) + power(5034,c) + power(5049,c) + power(5085,c) + 2*power(5089,c) + power(5097,c) + power(2,1. + 3.*c)*power(5287,c) + power(5324,c) + power(5389,c) + power(5565,c) + power(5623,c) + power(6080,c) + power(6380,c) + power(6477,c) + power(6740,c) + power(7192,c) + power(7447,c) + power(7644,c) + power(7837,c) + power(7843,c) + power(7922,c) + power(8738,c) + power(10089,c) + power(10237,c) + power(10258,c) + power(10491,c) + power(10625,c) + power(10982,c) + power(11175,c) + power(11411,c) + power(11442,c) + power(11811,c) + 2.*power(12559,c) + power(12791,c) + power(13121,c) + power(13486,c) + power(14708,c) + power(15251,c) + power(15261,c) + power(15277,c) + power(15806,c) + power(16185,c) + power(16229,c) + power(16358,c) + power(17168,c) + power(17458,c) + power(17758,c) + power(18287,c) + power(18568,c) + power(18728,c) + power(19556,c) + power(20567,c) + power(21012,c) + power(21308,c) + power(23063,c) + power(24127,c) + power(25910,c) + power(26770,c) + power(27753,c) + power(28460,c) + power(28493,c) + power(29361,c) + power(30085,c) + power(32408,c) + power(35338,c) + power(36799,c) + power(37642,c) + power(37654,c) + power(37915,c) + power(39715,c) + power(40580,c) + power(42015,c) + power(42045,c) + power(42188,c) + power(45406,c) + power(46653,c) + power(47596,c) + power(48296,c) + power(49171,c) + power(49416,c) + power(50145,c) + power(52042,c) + power(52489,c) + power(52875,c) + power(53321,c) + power(53443,c) + power(54433,c) + power(55381,c) + power(56463,c) + power(56485,c) + power(56560,c) + power(57042,c) + power(62551,c) + power(62651,c) + power(62661,c) + power(63732,c) + power(64103,c) + power(64893,c) + power(71043,c) + power(74364,c) + power(75409,c) + power(76057,c) + power(81542,c) + power(82702,c) + power(84566,c) + power(88682,c))*b + 1266.5546418385234*(-1 + c) + 136.*log((136.*power(2.718281828459045,power(88682,c)*b))/(-1 + power(2.718281828459045,power(88682,c)*b))) + 136*log(b) + 136*log(c);
contour(b,c,z)
The thing to keep in mind is that Mathematica is formula-oriented and is programmed in terms of mathematical variables, while Matlab is numerically oriented and programmed in terms of matrices and arrays. To evaluate a function of two variables on a grid, it is necessary to first generate that grid explicitly in the form of arrays, and then to take care to use the element-wise operators (
.*
,./
etc.) instead of the matrix operators. Here is the code:I also took the liberty to slightly syntax-normalize and simplify your formula (e.g,
power(2.718..., x)
isexp(x)
).Here's the result:
If you want more contour lines, use something like
contour(b, c, z, 100)
.To understand what I've done here, read Array vs. Matrix operations and
meshgrid
from the Matlab documentation. Because.*
means something else than*
in Matlab, one should also take care not to have trailing decimal points in expressions, like3.*B
, though it doesn't really do any harm in that case.