MATLAB Answers


Why I can't load the life?

Asked by Isida Kaloshi on 10 Nov 2018
Latest activity Commented on by Stephen Cobeldick on 11 Nov 2018
I want to load a file collection1.txt
So I wrote
function [output]= calculate_tfidf('E:\backup\Media\collection1.txt')
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


Sign in to comment.

1 Answer

Answer by Walter Roberson
on 10 Nov 2018
Edited by Walter Roberson
on 10 Nov 2018

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);
and you should invoke it like
output = calculated_tfidf('E:\backup\Media\collection1.txt');


Show 1 older comment
Store the next 3 lines in calculate_tfidf.m
function [output] = calculate_tfidf(filename)
output = load(filename);
Now go to the command line and invoke
output = calculated_tfidf('E:\backup\Media\collection1.txt');
Dera Mr Roberson, thank you again for your reply. I stored the 3 line in calculate_tfidf.m and I went to command window to invoke output = calculate_tfidf('E:\backup\Media\collection1.txt');
but I'm getting to errors
Error using load Number of columns on line 2 of ASCII file E:\backup\UNIVIE\MRS\collection1.txt must be the same as previous lines.
Error in calculate_tfidf (line 3) output = load(filename);
@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.

Sign in to comment.