prevent function from displaying output
5 次查看(过去 30 天)
显示 更早的评论
I have the following function (please do not suggest that i change the function itself):
function [sumf] = delet();
for i = 1:2;
syms d u ;
f = (char(vpa(subs((d/u - strcat('k',num2str(i))),{d,u},{1,2}))));
a = symvar(char(vpa(f)));
f = ['@(', sprintf('%k1,', a{1:end-1}), a{end}, ') ',f];
f = eval(f);
x = strcat('f',num2str(i));
eval(sprintf('%s = f',x));
end
sumf = @(k) f1(k(1))+f2(k(2));
once called : f = delet; f = delet;
f =
0.5 - 1.0*k1
f1 =
@(k1)0.5-1.0*k1
f =
0.5 - 1.0*k2
f2 =
@(k2)0.5-1.0*k2
on the display. how do i stop this ?
1 个评论
Razvan
2012-9-28
What exactly do you want to stop? Your question is very unclear... Probably you want to remove the
eval(sprintf('%s = f',x));
line, if you don't want this to display your functions...
采纳的回答
更多回答(3 个)
Muthu Annamalai
2012-9-28
Changes, like the previous comments suggest, using a semi-colon, should stop output form appearing on your terminal.
Also you want to explore 'str2func()' as a way to build function handles.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!