From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
03-16-2012 08:11 PM
Hi
I have data (see attachment) that I'd like to fit with a piecewise function defined as
y(x)=A, if x<B
y(x)=A+(x-B)^C, if x>B
I learned how to use non-linear fitting VI to fit the data with the power law function over the entire inverval, but can not figure out yet how to introduce that condition for the argument.
I also saved the data into the attached VI.
Any help would be greatly appreciated.
Regards,
Misha
Solved! Go to Solution.
03-17-2012 09:53 AM
I hope this one didn't end up too messy to understand.
I tried to keep it as general as possible so some things you wont need.
Ask if you dont understand something 🙂
See ya, and good luck!
(dont forget to kuddo and mark as solved 🙂
03-17-2012 11:52 AM - edited 03-17-2012 11:53 AM
mihonyc wrote:y(x)=A, if x<B
y(x)=A+(x-B)^C, if x>B
That's not good, because you have a gap where x=B. One of the sides need to include an "equal" 😄
Writing a model that switches formulas based on X is simple. All you need is another parameter B and a case structure. The problem is in the discrete nature of the x data, which could cause problems for the partial derivatives. Since B is actually a parameter in the second function, I think it should work just fine. What have you tried so far?
03-17-2012 11:52 AM
@Nihil wrote:
I hope this one didn't end up too messy to understand.
(Nihil: the VI you have attached seems corrupt and cannot be opened. What is the LabVIEW version?)
03-17-2012 12:03 PM
03-17-2012 12:19 PM
altenbach, oops! here it goes again, (LV2010)
😉 thanks for taking a look
03-17-2012 12:19 PM - edited 03-17-2012 12:39 PM
Seems to work just fine, but I think the model is insufficient for the data.
Here is a quick draft.
03-17-2012 12:35 PM
@Nihil wrote:
altenbach, oops! here it goes again, (LV2010)
😉 thanks for taking a look
OK. You probably did not notice that the VI in the original question was LabVIEW 8.6, meaning he won't be able to look at your VI. Since you don't really answer the question about fitting, it probably does not really matter. 😉
There are a couple of problems with your code, for example uncoditionally building an array in a FOR loop using a shift register and a "built array" node is very inefficient. All you need is autoindexing at the right loop boundary. Autoindexing is significantly better because LabVIEW knows how big the array will be and can allocate it when the loop starts. You also don't need to wire [x] across the case structure, because the output is identical for all cases. Same with the X-array and the FOR loop. You already have the x-array fully formed before the loop starts, thus it does not need to be re-build inside the loop. They y array is the only item that needs to exit the loop, the x array can be wired around for the second bundle operation.(The LabVIEW compiler, especially in very recent version is getting better at recognizing these things and doing corrections under the hood, but why risk it?)
03-17-2012 01:23 PM
hey! thanks Alternbach 😉
i've just come to understand the original question
03-19-2012 02:37 PM
Thanks a lot
That's exactly what I was looking for
Misha