Calling a Function From Another Function
1 次查看(过去 30 天)
显示 更早的评论
I created a function called table(data) which returns a matrix with labels from the data. I would like to try and create another function which can use table(data). The reason I would like to learn this is because if I create a new function it will have to be by using just data again. I would like to use the new created data in future functions and scripts.
This is what I though I would work which it didn't.
function []=food(table(data))
However, that doesn't work because it returns unbalanced or unexpected parenthesis or bracket.
5 个评论
per isakson
2017-12-8
The statement "I created a function called table(data) which returns a matrix" confuses me.
T = table( data );
returns a table object, not a matrix. Thus I assumed that you had used the name table for your own function.
回答(1 个)
per isakson
2017-12-8
编辑:per isakson
2017-12-8
M = table_1( data );
food( M );
or
food( table_1( M ) );
The two line construct is easier to debug
where
function food( m )
% m is a numerical matrix
...
end
8 个评论
per isakson
2017-12-8
I changed my answer back to the original one, which shows the syntax you are asking for.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!