Syntax for matlabFunction to produce vector variables and scalar variables
显示 更早的评论
When doing this:
syms x y z t
r = (x^2 + y^2 + z^2)*exp(-t);
matlabFunction(r, 'file', 'my_function',...
'vars', {t, [x y z]});
The resulting function operates on vectors:
function r = my_function(t,in2)
%MY_FUNCTION
% R = MY_FUNCTION(T,IN2)
x = in2(:,1);
y = in2(:,2);
z = in2(:,3);
r = exp(-t).*(x.^2+y.^2+z.^2);
How should I write matlabFunction if want the following;
function r = my_function(t,in2)
%MY_FUNCTION
% R = MY_FUNCTION(T,IN2)
x = in2(1);
y = in2(2);
z = in2(3);
回答(2 个)
Azzi Abdelmalek
2013-1-30
function [x,y,z] = my_function(t,in2)
3 个评论
Giorgos Papakonstantinou
2013-1-30
Azzi Abdelmalek
2013-1-30
You said, in my initial post matlabFunction returns in2 , in2 is an input to your function not an ouput
Giorgos Papakonstantinou
2013-1-30
类别
在 帮助中心 和 File Exchange 中查找有关 Variables 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!