fedvasu
fedvasu

Reputation: 1252

trouble with my octave function

I think I am missing something very basic here

function F = non_iter(x,kc,kw) 
 F = [x(6)*x(4)*kc-3*x(2);
     x(2)*x(5)-kw*x(6)*x(3);
     x(2)+x(6)-1;
     x(1) -7.52;
     x(6)+2*x(4)+2*x(2)+x(3)-4;
     x(3)+x(5)-8];
end

when I call this, like

fu = non_iter(x,kc,kw)

It says vertical dimension mismatch (3x1 vs 1x2)

x is supposed to be a row vector of length 6 and kc and kw are scalars. I have other functions with vector and scalar arguments but they don't return a column vector.

I tried with this function in separate file as well as make it inline with @ operator.

Upvotes: 0

Views: 80

Answers (1)

rozsasarpi
rozsasarpi

Reputation: 1641

This version is working for me on Matlab.

function F = non_iter(x,kc,kw) 
 F = [x(6)*x(4)*kc-3*x(2);
     x(2)*x(5)-kw*x(6)*x(3);
     x(2)+x(6)-1;
     x(1)-7.52;
     x(6)+2*x(4)+2*x(2)+x(3)-4;
     x(3)+x(5)-8];
end

In the 4th row of F the white space is treated as a separator for two entries, it should be removed. Additionally, there is an unnecessary bracket.

Upvotes: 2

Related Questions