Error message Error using mupadengin​e/feval_in​ternal More equations than variables is only supported for polynomial systems. Error in sym/vpasolve (line 172) sol = eng.fe

Hello I am trying to find all the values of C for the following equation in a 2D matrix:
eqa = exp(-r2.*C.*Te) .* (((1 - exp(-P-(r1.*C.*Tr)) - cosAb.*(exp(P) - exp((-2.*P)-(r1.*C.*Tr)))))./(1 - exp(P) - cosAb.*(exp(P-(r1.*C.*Tr)) - exp((-2.*P)-(r1.*C.*Tr))))) - 1 == E
I tried to use vpasolve but i keep getting this same error:
Error using mupadengine/feval_internal
More equations than variables is only supported for polynomial systems.
Error in sym/vpasolve (line 172)
sol = eng.feval_internal('symobj::vpasolve',eqns,vars,X0);
Error in editorequationstwo (line 40)
J = vpasolve(eqa, C)
Can some one help me find what I am doing wrong?
Code I used is:
app.Ei = cast(niftiread("Ei_volume.nii"),'double'); %96 x 80 x 72 x 146
app.T10 = cast(niftiread("new_T1map_T1.nii.gz"),'double'); %96 x 80 x 72
app.Brainmask = cast(niftiread("irp_brain_mask.nii.gz"),'double'); %96 x 80 x 72
Eii = app.Ei .* app.Brainmask;
size(Ei) % 96 x 80 x 72 x 146
T100 = app.T10 .* app.Brainmask;
size(T10) % 96 x 80 x 72
syms r2 Ei Te Tr P r1 cosAb C
Ei = Eii(:,:,36,16);
r2 = 6.7;
Te = 0.00137; %seconds
Tr = 0.003; %seconds
T10 = T100(:,:,36,:);
r1 = 4.2;
Ab = 9; %degrees
Ab = deg2rad(Ab); %inradians
cosAb = cos(Ab);
P = Tr./T10;
eqa = exp(-r2.*C.*Te) .* (((1 - exp(-P-(r1.*C.*Tr)) - cosAb.*(exp(P) - exp((-2.*P)-(r1.*C.*Tr)))))./(1 - exp(P) - cosAb.*(exp(P-(r1.*C.*Tr)) - exp((-2.*P)-(r1.*C.*Tr))))) - 1 == Ei;
J = vpasolve(eqa, C)

 Accepted Answer

Your T10 is a 4 dimensional array so your P becomes 4 dimensional. In order to vpasolve an expression involving that array, you would have to have as many variables as the size of that 4 dimensional array.
vpasolve is a simultaneous equation solver: it tries to find a set of values of the variables that solves all of the passed equations simultaneously. When you have more equations than variables then the only way that would be possible in theory is if many of the equations are redundant.
If you want to solve the same general equation with many different specific values then use arrayfun()

4 Comments

Thank you very much for your answer I shall use arrayfun().
Do you think using fsolve would work better to solve the equation using these arrays?
Did you try to plot
f = @(C)exp(-r2.*C.*Te) .* (((1 - exp(-P-(r1.*C.*Tr)) - cosAb.*(exp(P) - exp((-2.*P)-(r1.*C.*Tr)))))./(1 - exp(P) - cosAb.*(exp(P-(r1.*C.*Tr)) - exp((-2.*P)-(r1.*C.*Tr))))) - 1 - Ei;
as a function of C ?
This way, you will get an impression where the roots of your equation are located (if there are any).
Hello Torsten, Thanks to your recommendation I have plotted it now and it gives an idea of the roots for each individual point.
Do you happen to know how I can do this for a 2D array? so that the code can calculate the root value for each individual point and output a 2D array of the results?
Do you happen to know how I can do this for a 2D array? so that the code can calculate the root value for each individual point and output a 2D array of the results?
I don't know exactly what you mean. Could you give a simple example ?

Sign in to comment.

More Answers (0)

Asked:

on 5 Feb 2023

Commented:

on 6 Feb 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!