TrueTears
TrueTears

Reputation: 117

MATLAB error when solving simultaneous equations

I am running a MATLAB code which solves a set of non-linear simultaneous equations. The code can be found here. The data input for the code (in excel) can be found here.

I encounter the following error:

Error using sym/subsasgn (line 733)
Indexed assignment to empty SYM objects is supported only in the 0-by-0 case.

Error in Solution (line 69)
    x(i,:) = (b(i,1) - b0)./(c(i,1)*x0) + c0/c(i,1);

Does anyone have any idea how I can resolve this?

Upvotes: 0

Views: 257

Answers (1)

Daniel
Daniel

Reputation: 36720

When declaring a symbolic variable, you have to specify the dimensions, otherwise it's a scalar. Instead of syms x; use sym and set the dimension argument:

x=sym('x',[3,4])

Replace [3,4] with the dimensions you want.

Upvotes: 1

Related Questions