The goal is to solve the following system of 2 non linear equations in simulink. We have to find x and y such as:
where A, B, P1 and P2 are variables.
Before going to simulink I wrote the folloing m-file
function F = anothertrial(xy,A,B,P1,P2)
and I have saved this m-file under the name: anothertrial.m
My simulink model is containing two parts (two groups of blocks). In the first part, complicated calculations are done for the calculation of A, B, P1 and P2 and each one of them is sent to the workspace through the use of 4 blocks "to workspace" and each time the name of the variable in the "to workspace" block has been changed to A, B, P1 and P2 successively.
The second part of my model is containing only 3 blocks:the first block is "from workspace" and the name of the data of this block has been changed to xy0. The output of this block is connected to a "matlab function" block of which the matlab function space has been filled with the expression:
and finally the output of this block is connected to "display" block.
before starting the simulation I typed in the command window the value of the guess for the fsolve function:
The idea is to run a simulation of the model in which the simulation of the two parts of the model is done simultaneously in this way: The values of A, B, P1 and P2 are calculated in the first part of the model and sent to the workspace, then when A, B, P1 and P2 become available in the workspace they are used by the "matlab function" block (the fsolve block) to solve the given system of non linear equations.
When the model is run the simulation is stopped and error messages are generated.
1/when the first part of the model is put in an independent model and run the values of A,B,P1 and P2 are calculated and displayed on the "display" blocks.
2/When the second part of the model is put in an independant model and run, after typing in the command window the values of A, B, P1, P2 and the guess XY0, the system of the non linear equations is solved and values for X and Y are displayed in the "display" block.
It seems that when the simulations of the two parts of the model are run simultaneously the values of A, B, P1 and P2 are not accessible to the "fsolve function" block in the second part.
Please is there any solution to my problem????
Help me please.