Problem using the erfi function from Mupad in Matlab command Window
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello every one, I want to use the erfi function, and since it doesn't exist in Matlab I tried to call it from Mupad. It works fine for numbers like 1, 1.3, .. however, it doesn't work for an array this is my function :
function ans=erfi(t)
f = feval(symengine,'erfi',t);
format long;
ans = double(f);
and when I put in the command window:
>> erfi(1)
erfi (1.3)
erfi(2)
ans =
1.650425758797543
ans =
2.956086576851622
ans =
18.564802414575553
it works. But when I put ( and that's what I need) :
>> erfi([1;2;3])
??? Error using ==> mupadengine.mupadengine>mupadengine.feval at 144
MuPAD error: Error: argument must be of 'Type::Arithmetical' [erfi]
Error in ==> erfi at 2
f = feval(symengine,'erfi',t);
I have this as an error... I hope I explained my problem for you guys..I'm waiting for you help Thanks :)
0 comentarios
Respuestas (1)
Andrei Bobrov
el 8 de Jul. de 2011
correct
function out=erfi(t)
out = arrayfun(@(i1)double(feval(symengine,'erfi',t(i1))),1:length(t));
end
EDIT
function out=erfi(t)
out = zeros(1,numel(t));
for i1 = 1:numel(t)
out(i1) = double(feval(symengine,'erfi',t(i1)));
end
end
2 comentarios
Andrei Bobrov
el 8 de Jul. de 2011
We use function 'arrayfun' , read help about 'arrayfun', more can use loops 'for...end'. see answer EDIT.
Ver también
Categorías
Más información sobre Error and Exponential Integral Functions en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!