Message Boards Message Boards

Assistance with solving coupled equations using module with external file

Dear All,
I am seeking your assistance in solving a system of two coupled equations using a Module that involves writing to and reading from an external file. To clarify my requirement, I have included an example program below that demonstrates my approach. However, the current implementation does not work as intended.
Could you please help me identify and correct the issues in my program? Your guidance would be greatly appreciated.

FF[xx1_, xx2_] := Module[
   {xxx1 = xx1, xxx2 = xx2, FF1, FF2},

   ClearAll[FileC];
   FileC = "C:\\Mohsen-Files\\MLSF\\W-1\\MLSF.3\\MLSF\\C.txt";

   OpenWrite[FileC];
   WriteString[
    FileC,
    Sin[xxx1], "\n",
    Cos[xxx2]
    ];

   Close[FileC];

   ClearAll[DataC];
   DataC = Import[FileC, "Table"];

   ClearAll[FF1, FF2];
   FF1 = xxx1*DataC[[1, 1]];
   FF2 = xxx2*DataC[[2, 1]];

   {FF1, FF2}

   ];

FindRoot[
 FF[x1, x2] == {0.0, 0.0},
 {{x1, \[Pi]/4}, {x2, \[Pi]/4}}
 ]
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract