How to run matlab script in knime

Hi,

how can i run a script that i've wrote in "MATLAB Snippet", how to deal with the kIn and mOut? how to read the table from a previous node and make a new table - text as output? what i have to change in my script so it can work ??

this is my code:

[M,text,alldata]=xlsread('test2.csv'); % M is numeric date 
                                       % text is the text :-)
                                       % all data is both M + text

[r c]=size(M);
S=sum(M,2)-1; %sum rows -1 of the diagonal
good_ones = ones(1,size(M,1));

% loop over rows 
for row=1:r-1; %last row will be=1 only
    if good_ones(row)==1;
        for col=row+1:c;  % go over upper triangle only !
            if good_ones(col)==1;
                if (M(row,col) >= 0.7); %if the value >= 0.7 then we compare the sum vector
                    if S(row)>S(col); % if the sum of the row line is larger we delete this line
                        good_ones(row) = 0;
                        break % & we don't continue comparing this line
                        
                    else % the sum of the col line is larger so we delete it
                        good_ones(col) = 0;
                    end
                end
            end
        end
    end
end
new_M = M(find(good_ones),:);  % generate a new matrix for the "good" molecules
new_text = text(find(good_ones)+1,1); % keep the names of the "good" molecules

 
    %save the file
    fid=fopen('comp_cb1antagonist_scrip1.txt','w+'); %name it as you wish
    [r2,c2]=size(new_M);
    for i=1:r2
        fprintf(fid, '%s \n',new_text{i,1});
    end
    fclose(fid);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

** how can i check if i have the "Statistics Toolbox" ??

Hi

sorry for the late reply... If it is still any help: First I would suggest that you use knime nodes to read the data. then just connect the reader node to a matlab snippet node. There your table is by default a dataset with the variable name kIn. Here you need to adapt your script in order to access the data in kIn correctly. Alternatively you can change the matlab type in the knime preferences to containters.Map or struct. Once the data is processed. assign it to mOut. The node will than take care to parse it back into a knime table.

Felix