where is the error in my code?

Hi every one,
I would like to plot the relationship between the integral (fun) and the variable (w) from 1 to 4 and I used the following code. However, the plot seems to be wrong! where is the error?
syms w x
V1 = @(w) -acosh(10*(w./(21))^(1/2))/10000000000;
V2 = @(w) acosh(10*(w./(21))^(1/2))/10000000000;
fun = @(x,w)0.0018./((w./((cosh(10^10.*x./1)).^2)-(0.21)).^0.5);
q = @(w) integral(@(x)fun(x,w),V1(w),V2(w));
w = 1:4;
fplot(w,q)

Answers (1)

V1 = @(r,w) -acosh(10*(w/(1600*r + 21))^(1/2))/20000000000;
V2 = @(r,w) acosh(10*(w/(1600*r + 21))^(1/2))/20000000000;
% Define function to be integrated
fun = @(x,r,w)2.3*r.*0.0018./((w./((cosh(10^10.*x./0.5)).^2)-(r.*16+0.21)).^(1/2));
r = 0.001:0.001:0.07;
w = 0:0.1:5;
[R,W] = meshgrid(r,w);
F = @(r,w)integral(@(x)fun(x,r,w),V1(r,w),V2(r,w));
result = arrayfun(F,R,W)
result = 51×70
1.0e-13 * 0.0137 0.0264 0.0384 0.0497 0.0604 0.0705 0.0802 0.0895 0.0984 0.1069 0.1151 0.1231 0.1308 0.1382 0.1454 0.1524 0.1592 0.1659 0.1723 0.1787 0.1848 0.1908 0.1967 0.2025 0.2082 0.2137 0.2191 0.2245 0.2297 0.2349 0.0136 0.0262 0.0381 0.0493 0.0599 0.0700 0.0796 0.0888 0.0976 0.1061 0.1143 0.1222 0.1298 0.1372 0.1444 0.1514 0.1581 0.1647 0.1712 0.1774 0.1836 0.1896 0.1954 0.2012 0.2068 0.2123 0.2177 0.2230 0.2282 0.2334 0.0136 0.0262 0.0381 0.0493 0.0599 0.0699 0.0795 0.0887 0.0976 0.1060 0.1142 0.1221 0.1297 0.1371 0.1443 0.1512 0.1580 0.1646 0.1710 0.1773 0.1834 0.1894 0.1952 0.2010 0.2066 0.2121 0.2175 0.2228 0.2280 0.2331 0.0137 0.0264 0.0384 0.0497 0.0604 0.0699 0.0795 0.0887 0.0975 0.1060 0.1141 0.1220 0.1296 0.1370 0.1442 0.1511 0.1579 0.1645 0.1710 0.1772 0.1833 0.1893 0.1951 0.2009 0.2065 0.2120 0.2174 0.2227 0.2279 0.2330 0.0137 0.0264 0.0384 0.0497 0.0604 0.0705 0.0802 0.0895 0.0984 0.1069 0.1151 0.1219 0.1296 0.1369 0.1441 0.1511 0.1578 0.1644 0.1708 0.1771 0.1832 0.1892 0.1950 0.2008 0.2064 0.2119 0.2173 0.2226 0.2279 0.2329 0.0137 0.0264 0.0384 0.0497 0.0604 0.0705 0.0802 0.0895 0.0984 0.1069 0.1151 0.1231 0.1308 0.1382 0.1454 0.1524 0.1592 0.1659 0.1708 0.1770 0.1831 0.1891 0.1950 0.2007 0.2063 0.2118 0.2172 0.2225 0.2277 0.2328 0.0137 0.0264 0.0384 0.0497 0.0604 0.0705 0.0802 0.0895 0.0984 0.1069 0.1151 0.1231 0.1308 0.1382 0.1454 0.1524 0.1592 0.1659 0.1723 0.1787 0.1848 0.1908 0.1967 0.2025 0.2063 0.2117 0.2171 0.2224 0.2276 0.2328 0.0137 0.0264 0.0384 0.0497 0.0604 0.0705 0.0802 0.0895 0.0984 0.1069 0.1151 0.1231 0.1308 0.1382 0.1454 0.1524 0.1592 0.1659 0.1723 0.1787 0.1848 0.1908 0.1967 0.2025 0.2082 0.2137 0.2191 0.2245 0.2297 0.2349 0.0137 0.0264 0.0384 0.0497 0.0604 0.0705 0.0802 0.0895 0.0984 0.1069 0.1151 0.1231 0.1308 0.1382 0.1454 0.1524 0.1592 0.1659 0.1723 0.1787 0.1848 0.1908 0.1967 0.2025 0.2082 0.2137 0.2191 0.2245 0.2297 0.2349 0.0137 0.0264 0.0384 0.0497 0.0604 0.0705 0.0802 0.0895 0.0984 0.1069 0.1151 0.1231 0.1308 0.1382 0.1454 0.1524 0.1592 0.1659 0.1723 0.1787 0.1848 0.1908 0.1967 0.2025 0.2082 0.2137 0.2191 0.2245 0.2297 0.2349

Tags

Asked:

on 25 Jun 2022

Answered:

on 25 Jun 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!