Help needed for quad function
4 views (last 30 days)
Show older comments
clear
clc
EF = linspace(-.2, 1.2, 100)';
n = (EF - 1.12)/.026;
epsi = @(E)(E-1.12)/.026;
xyz = @(epsi)sqrt(epsi)./(1+exp(epsi-n));
y = quad(xyz, 0, 50);
ok, my code is as above. and it keeps complaining the matrix dimension must agree. If someone can fix the error or comment it would be much appreciated.
0 Comments
Answers (1)
Walter Roberson
on 15 Nov 2011
Using epsi as both the name of an anonymous function, and the dummy parameter of a different anonymous function, is asking or trouble (IMHO.)
quad is going to call your xyz routine and pass it in a vector argument as the first parameter, and expect a vector argument as output.
Your xyz routine will use espi just as the name of the dummy parameter, so within xyz, "espi" is the vector of x values passed to xyz. sqrt() of that vector is well defined and returns a vector of the same length [as the vector of x values passed to xyz]. But then in the denominator, you have 1+exp(espi-n) . We know the size of espi (the number of values passed to xyz), but what is the size of n? By looking two lines above that, we can see that n will depend upon the size of EF, and by looking at the line above that, we know that EF will have the length 1000; popping up, we know that the "n" in expi-n will have length 1000. But is the length of espi 1000 ? Probably not, so the subtraction will likely not work.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!