Need help coding this algorithm

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • flavourofbru
    New Member
    • May 2007
    • 48

    Need help coding this algorithm

    Hi,

    I am stuck at a major part of the code in VC++.

    My algorithm is as follows:


    f_name = load(filename);
    //this also loads a text file. The text files contains numbers sepearted by tab. it has 4 columns in it.

    sum_text = sum(f_name(:, 4)) + 1;
    // here we are calculating the sum of the 4th column elements and then adding 1 to it.

    [Rows, Columns] = size(f_name);
    //this computes the number of rows and columns in the text file, i.e. Rows contain no.of rows andcontains no.of columns in the text file

    Matched = find(f_name(:, 4) >= 20);
    //this will find which row has its 4th column element > 20 and returns that row number. It will contain all row numbers that satisfy the condition --> its 4th column element >= 20

    for p = 1:length(Matche d)
    {
    R = f_name(Matched( p), 1);
    //for example if the 1st row satisfies the above condition, then this will compute or return 1st row first element

    G = f_name(Matched( p), 2);
    //this will return 1st row, 2nd element

    B = f_name(Matched( p), 3);
    //this will return 1st row, 3rd element
    }

    Can someone help coding this one.
    This is for my student project. Need help

    Thanks,
    Rishi
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    Which part of the algorithm, specifically, are you having trouble coding?

    Comment

    Working...