Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
Hi, and Merry Xmas
I' trying to work with LeastSquaresFit and functions and variables NOT unitless, and I'm having problems.
I have a variable and some data obtained by interpolation
I want to find a value for such that the function
fits the y values.
I have defined
Dimensionally everything seems correct:
But, when I try to use
I get: "These units are not compatible".
Which units? Everything now is unitless!
Thanks
Please include your worksheet, you may need to put it in a zip file.
Cheers
Terry
If you click on your LeastSquaresFit expression, go to the Calculations tab, and click on the Error Tracing arrows, where does the calculation trail lead back to? Which expression does it point to?
Stuart
From what you show it looks like it should work OK, so the error may be in the parts you don't show. That's the values in Matrix M and most importantly the definition of your function Z0. It may be that in some cases this function returns a dimensionless zero, while in other cases it returns a quantity with units. This can often work well, but in some cases it can lead to problems.
And then - error messages in Prime are not always accurate. The error does not necessarily have to do directly with the units.
I would therefore also recommend that you post your Prime sheet here. Either together with the data CSV file or with the data in a Matrix M that is already integrated in the Prime sheet (although this would be difficult to do in Prime).
Without the sheet, we can only grope in the dark and helplessly suggest one thing or another.
Apart from error tracing (which may refer to the Z0 function) as suggested by Stuart, you could also try omitting the optional arguments in the LeastSquareFit function (i.e., the last two) and see if the problem persists (I guess it will).
Or you could try your luck with the genfit function.
genfit(x,y, ß, GW)= should also give you a suitable value for ß.
It's only a guess, but your expression
is looking for a set of values, one for each set of values of x and y.
Often with this error vectorizing the RHS will allow computation to succeed; an alternative would be to create a function and solve for each point.
The attached program demonstrates a least squared fit of data to a polynomial function. It works without the LeastSquaresFit function and runs in Prime Express, (built in version 4).
Since you haven't shared What your expression should look like you can try this on your data to get curves that fit polynomial functions of sigma.
Smarter people than I might be able to adapt this scheme to other function types.
Good luck.
Add the file, dummy!
For some reason I can't attach the file. But it's not large.
Hi Fred,
There's a problem with the forum (again).
You need to zip the file before attachment.
Success!
Luc
Your example is dimensionless. In this case everything works even for me! See my reply.
Hi, working with dimensionless variables in all the worksheet, since the beginning, everything works:
However
and
Those errors lead back to
However
So I don't understand why "Those units are not compatible".
To provide the source code I need some time to clean it up.
Thanks
Please don't mind the slight numerical difference: I know where it comes from and it's unimportant!
The top of your expression has units and the bottom doesn't.
This triggers that error! Investigate Topen
@Fred_Kohlhepp wrote:
The top of your expression has units and the bottom doesn't.
This triggers that error! Investigate Topen
Wouldn't this just mean that Zopen is of unit Rayl/m² = kg/(m4*s) ?
From that screenshot we don't even see which version it stems from, if sigma is unit-less 350 or if its 315 Rayl.
We still don't see the definition of Topen, Zout or aL and how Zopen is related to Zo (which obviously is of unit Ohm).
I guess we will have to wait until @ptc-1681201 finally sends the sheet along with the data before we can make any assumptions about the error.
I believe that there's a clue:
The top expression has units, the bottom doesn't, The only difference between the top and the bottom is the terms of T_open(1,1) and T_open(1,2).
Yes, it might look odd, and I also would have expected the unit ohms for a variable Z.... But after all we're not seeing the "big picture."
@Fred_Kohlhepp wrote:
I believe that there's a clue:
The top expression has units, the bottom doesn't, The only difference between the top and the bottom is the terms of T_open(1,1) and T_open(1,2).
