Why I can't load the life?
3 次查看(过去 30 天)
显示 更早的评论
Hello,
I want to load a file collection1.txt
So I wrote
function [output]= calculate_tfidf('E:\backup\Media\collection1.txt')
end
But when I run the program to see if file has been loaded I get the message bellow
Error: File: calculate_tfidf.m Line: 2 Column: 36
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct
matrices, use brackets instead of parentheses.
Thank you in advance
0 个评论
回答(1 个)
Walter Roberson
2018-11-10
编辑:Walter Roberson
2018-11-10
The only operations that can be present in a "function" line are:
[] -- around the list of output variables only, no-where else on the line
() -- around the list of input variables only, no-where else on the line
comma -- separate the list of input variables and list of output variables
~ -- replacing one of the input variables, indicating it should be ignored
Calculations and indexing of all varieties are not permitted.
In particular it is never valid to have a quoted string in the function line.
Your code should look like
function [output] = calculate_tfidf(filename)
output = load(filename);
end
and you should invoke it like
output = calculated_tfidf('E:\backup\Media\collection1.txt');
4 个评论
Stephen23
2018-11-11
@Isida Kaloshi: load is not suitable for importing your text file. Either pick a method yourself from the available text-file importing functions:
or upload a sample file by clicking the paperclip button, and we will help you.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!