Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8937725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:27:56+00:00 2026-06-15T10:27:56+00:00

I am working with Matlab to use Rocchio Classification method. I have 160 txt

  • 0

I am working with Matlab to use Rocchio Classification method. I have 160 txt documents.
I have calculated term frequency of each word in each document, so now have a 1×160 cell array “Set” which consist of 160 cells with a number of integers in each cell (Terms Frequencies of each word in a document).
I am trying to take each integer i, and apply next formula 1+log10(i), to calculate term frequency weighting. I came up with next code:

function [tfw]=TFWeighting(Set)
size(Set);
TFW=cell(0);
for i=1:size(Set)
    for j=1:size(Set{1,i})
       TFW{1,i}(j,1) = 1+log10(Set{1,i}(j,1));
    end
end
tfw=TFW;
end

Well, it works but only for the first cell. All other 159 cells are untouched.
What might be the problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:27:58+00:00Added an answer on June 15, 2026 at 10:27 am

    this line:

    for i=1:size(Set)
    

    is your culprit.

    size(Set) is [1 160], so MATLAB says for i = 1:1;

    You want:

    for i=1:length(Set)
    

    The same potential bug happens a few lines later:

    for j=1:size(Set{1,i})
       TFW{1,i}(j,1) = 1+log10(Set{1,i}(j,1));
    end
    

    Without knowing whats in your Set, it’s hard to say, but I bet you can probably speed this whole thing up by removing the inner loop, and using MATLAB’s ability to process whole vectors or matrices at once:

    for i = 1:length(Set)
        TFW{i} =  1 + log10(Set{1,i}(:));
    end
    

    If you want to be SUPER fancy, here’s a one-line solution

    TFW = cellfun(@(c) 1 + log10(c),Set,'UniformOutput',false);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on replicating the load() function from MATLAB for use in a
I am working with a matlab project. And I have a text file like
This method is working totally right in matlab. but, when I compiled it in
I have been working lately on a number of iterative algorithms in MATLAB, and
I have recently been working with Matlab. My question stems from my usage over
I use to use IDL and MatLab in college and now that I have
I have been working with some friends to convert a Matlab Genetic Algorithm to
I have a method that that creates a MatLab array name from a file
I am working on a MATLAB GUI where I have to show a progress
I'm working in Matlab on using blockproc to process through an image and use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.