Hello all,I am trying to solve this in command window f = @(X)((x.^3)-2*(x.^2)-5*(x-3))*exp(x); Xn = (1:15)/16; fXn = f(Xn) And i am getting following error: Error using ==> mpower Matrix must be square.
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Shivangi Chauhan
am 25 Feb. 2016
Kommentiert: Shivangi Chauhan
am 25 Feb. 2016
Hello all,I am trying to solve this in command window
f = @(X)((x.^3)-2*(x.^2)-5*(x-3))*exp(x);
Xn = (1:15)/16;
fXn = f(Xn)
And i am getting following error: Error using ==> mpower Please suggest me.(this problem persists only when exponential function is with multiplication sign. ) Matrix must be square.
0 Kommentare
Akzeptierte Antwort
Stephen23
am 25 Feb. 2016
Bearbeitet: Stephen23
am 25 Feb. 2016
This fixes the error, but only you can check if it is correct:
>> f = @(x)((x.^3)-2*(x.^2)-5*(x-3)).*exp(x);
>> f(1:3)
ans =
24.465 36.945 180.770
You referred to the wrong variable (check your capitalization: X is not the same as x), and the last multiplication must be element-wise times, not matrix mtimes as you originally used. For more info:
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Operators and Elementary Operations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!