Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.9K Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Wrong result in mathematical model

Posted 10 years ago

I am a retired Electrical engineer, I have coded a model of a full wave rectified power supply. I have been using the model in Mathematica and Matlab.

The results are very close to what is expected with the Matlab model. However, Mathematica is giving the result for variable "BleederDischTime" off by a factor of 10^6 power. The equations are identical in the Mathematica model and the Matlab model. They were cut and pasted from Matlab to Mathematica. With proper fixing up of function brackets and equal signs of course. This truly appears to be a mathematica "bug" to me. I have to divide the "BleederDischTime" result, in Mathematica by 10^6 to get the same result Matlab gives without the same division. What is interesting is that I use a factor 0f 10^6 to convert Farads to Microfarads after the calculations are done for output. It seems unrelated to the "wrong result" described above. What could be going on here? I will post the Mathematica and identical Matlab files here. Thank you all!

Attachments:
POSTED BY: Kent J Jarvis
4 Replies
Posted 10 years ago

Ok, to be specific, I think I see now exactly what happened.

The way you defined things, when you do

BleederDichTime := ....

The value of CValue is one thing.

Then just a bit later, you change CValue (multiply it by 1000000).

Then, later, you print out BleederDichTime, and it evaluates the expression with the NEW value of CValue.

So everything is acting precisely as it should...

POSTED BY: Todd Moyer
Posted 10 years ago
POSTED BY: Kent J Jarvis
Posted 10 years ago

Oh good grief. I changed the := to = on the variable "BleederDischTime", and the problem went away. I have been having all kinds of problems with = vs := . I initially thought that if the value of a variable was going to change, such as in a loop, that just = made it work := caused something recursive to happen. Sometimes changing it made it worse. Anyway thanks for the tip. I just decided to try on the affected variable, and it works.

Sincerly, Kent

POSTED BY: Kent J Jarvis
Posted 10 years ago
POSTED BY: Todd Moyer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard