How to load a text file?









up vote
-1
down vote

favorite












I want to load a file collection1.txt. So I wrote:



function [output] = calculate_tfidf('E:backupMediacollection1.txt')
end


But when I run the program to see if file has been loaded I get the message below:




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.




What did I do wrong?










share|improve this question



















  • 1




    Please take a basic tutorial or read the documentation to learn how to define functions. You cannot just type random text and expect it to work. Did you type your exact question title in Google? Because that gives many working solutions.
    – Sardar Usama
    Nov 10 at 23:29










  • Have you looked at dlmread?
    – SecretAgentMan
    Nov 11 at 5:05














up vote
-1
down vote

favorite












I want to load a file collection1.txt. So I wrote:



function [output] = calculate_tfidf('E:backupMediacollection1.txt')
end


But when I run the program to see if file has been loaded I get the message below:




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.




What did I do wrong?










share|improve this question



















  • 1




    Please take a basic tutorial or read the documentation to learn how to define functions. You cannot just type random text and expect it to work. Did you type your exact question title in Google? Because that gives many working solutions.
    – Sardar Usama
    Nov 10 at 23:29










  • Have you looked at dlmread?
    – SecretAgentMan
    Nov 11 at 5:05












up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I want to load a file collection1.txt. So I wrote:



function [output] = calculate_tfidf('E:backupMediacollection1.txt')
end


But when I run the program to see if file has been loaded I get the message below:




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.




What did I do wrong?










share|improve this question















I want to load a file collection1.txt. So I wrote:



function [output] = calculate_tfidf('E:backupMediacollection1.txt')
end


But when I run the program to see if file has been loaded I get the message below:




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.




What did I do wrong?







matlab text-files






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 10:18









SecretAgentMan

397110




397110










asked Nov 10 at 23:20









user3052811

122




122







  • 1




    Please take a basic tutorial or read the documentation to learn how to define functions. You cannot just type random text and expect it to work. Did you type your exact question title in Google? Because that gives many working solutions.
    – Sardar Usama
    Nov 10 at 23:29










  • Have you looked at dlmread?
    – SecretAgentMan
    Nov 11 at 5:05












  • 1




    Please take a basic tutorial or read the documentation to learn how to define functions. You cannot just type random text and expect it to work. Did you type your exact question title in Google? Because that gives many working solutions.
    – Sardar Usama
    Nov 10 at 23:29










  • Have you looked at dlmread?
    – SecretAgentMan
    Nov 11 at 5:05







1




1




Please take a basic tutorial or read the documentation to learn how to define functions. You cannot just type random text and expect it to work. Did you type your exact question title in Google? Because that gives many working solutions.
– Sardar Usama
Nov 10 at 23:29




Please take a basic tutorial or read the documentation to learn how to define functions. You cannot just type random text and expect it to work. Did you type your exact question title in Google? Because that gives many working solutions.
– Sardar Usama
Nov 10 at 23:29












Have you looked at dlmread?
– SecretAgentMan
Nov 11 at 5:05




Have you looked at dlmread?
– SecretAgentMan
Nov 11 at 5:05












1 Answer
1






active

oldest

votes

















up vote
0
down vote













So you were defining a function, but you need to call that function,
In a modern version of Matlab you could code this something more like this:



 Tfidf=calculate_tfidf('E:backupMediacollection1.txt')


Now below that in the same file, define the actual function



 function output= calculate_tfidf(filename)
% now put your function cde in here
% Eg...

data = extractFileText(filename);
text = split(data,newline);
output = tokenizedDocument(text);

end





share|improve this answer




















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244380%2fhow-to-load-a-text-file%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    So you were defining a function, but you need to call that function,
    In a modern version of Matlab you could code this something more like this:



     Tfidf=calculate_tfidf('E:backupMediacollection1.txt')


    Now below that in the same file, define the actual function



     function output= calculate_tfidf(filename)
    % now put your function cde in here
    % Eg...

    data = extractFileText(filename);
    text = split(data,newline);
    output = tokenizedDocument(text);

    end





    share|improve this answer
























      up vote
      0
      down vote













      So you were defining a function, but you need to call that function,
      In a modern version of Matlab you could code this something more like this:



       Tfidf=calculate_tfidf('E:backupMediacollection1.txt')


      Now below that in the same file, define the actual function



       function output= calculate_tfidf(filename)
      % now put your function cde in here
      % Eg...

      data = extractFileText(filename);
      text = split(data,newline);
      output = tokenizedDocument(text);

      end





      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        So you were defining a function, but you need to call that function,
        In a modern version of Matlab you could code this something more like this:



         Tfidf=calculate_tfidf('E:backupMediacollection1.txt')


        Now below that in the same file, define the actual function



         function output= calculate_tfidf(filename)
        % now put your function cde in here
        % Eg...

        data = extractFileText(filename);
        text = split(data,newline);
        output = tokenizedDocument(text);

        end





        share|improve this answer












        So you were defining a function, but you need to call that function,
        In a modern version of Matlab you could code this something more like this:



         Tfidf=calculate_tfidf('E:backupMediacollection1.txt')


        Now below that in the same file, define the actual function



         function output= calculate_tfidf(filename)
        % now put your function cde in here
        % Eg...

        data = extractFileText(filename);
        text = split(data,newline);
        output = tokenizedDocument(text);

        end






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 11 at 9:05









        RichardBJ

        1415




        1415



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244380%2fhow-to-load-a-text-file%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Barbados

            How to read a connectionString WITH PROVIDER in .NET Core?

            Node.js Script on GitHub Pages or Amazon S3