Filter löschen
Filter löschen

Error using log Not enough input arguments. This is the error message I keep getting. Pls help

2 Ansichten (letzte 30 Tage)
%Write a .m script file that defines these two functions as anonymous functions and then plots
%boiling temperature against altitude in the range from ’500 ft to 14,439 ft (Colorados highest point).
clear all
h = linspace(-500, 14439, 1000);
p = @(h) 29.92 * (1 - 6.8753 * 10 .^(-6) * h);
p(h)
T = @(p) 49.161 .* log.*(p)+ 44.932;
T(p);
fplot(p,T);

Antworten (2)

Chunru
Chunru am 1 Sep. 2021
Don't confuse the function handle with numerical variables.
h = linspace(-500, 14439, 1000);
p = @(h) 29.92 * (1 - 6.8753 * 10 .^(-6) * h);
ph = p(h);
T = @(p) 49.161 .* log(p) + 44.932;
Tp = T(ph);
plot(ph,Tp);

Walter Roberson
Walter Roberson am 1 Sep. 2021
T = @(p) 49.161 .* log.*(p)+ 44.932;
^^^^^^^^
That means that the code should attempt to invoke the function named log with no parameters, and multiply the result returned by log by the value of p. Unless you do some unusual assignments higher in the code, that line of code is the same as if you had written
T = @(p) 49.161 .* log().*(p)+ 44.932;

Community Treasure Hunt

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

Start Hunting!

Translated by