04-01-2014 07:38 AM
Hi there!
I want to plot a Super Lorentzian function. It's shape is like that of a top-hat if you go to high enough powers. Problem is, I can't seem to plot it. I perform simple arithmetic to calculate the function and use the tics of a while loop with steps of 0.1 as my x-value.
However, when I hoop it up with a waveform chart or any plotting VI it goes nuts. It's max value is suppposed to be 1, but it displays values like 10^-59 if I define my step as 0.1. If I define it as just 1, it somewhat displays the function, but only displays it between two extremely large values.
The function is this:
A / (B + ((X-C)^n) + D
A/B defines the maximum value
X is ofcourse x, the input
C is horizontal transliteration
n is the power (I use 😎
D is vertical transliteration
In my case, it's max value is supposed to be 1. I know what it will look like, so I want to plot it between 0 and 4.
This is supposed to be something trivial, but yet I can't pull it off. How can I plot my function?
Solved! Go to Solution.
04-01-2014 09:28 AM
And this is something I just can't understand: it asks me for a 1D array of a cluster with 2 elements, which I give, only to say that they are not the same.
You can't see it well, but what I did was I used the bundle function to bundle the time which I converted into an array and the output of my function. Then I used the 'build array' VI to create an array of these two and voila, an error.
If I remove the array for my time (the iteration count) it will 'work', that is to say, it won't display an error. It does display extremely high values for the result and extremely low values (10^-52) for the x. This can't be right. What am I doing wrong?
04-02-2014 02:47 AM
Hello,
It's going wrong with the implementation of your steps.
The x-values in the first 4 iterations in your code are going like this:
0,1
1,1
2,1
3,1
4,1
...
I don't think this is what you want to obtain.
Please replace the "addition" by amultiplication (see attachment).
Please note that it is also dangerous to only check for "x equal to 4".
A better (but still not the best) way would be to check for "x equal to or greater than 4".
04-02-2014 03:22 AM
I just slapped myself in the face for it, because it's so logical.
Unfortunately, I came across another problem, one I couldn't understand. The iteration count starts at 0. So now it should go from 0 to 4 in steps of 0,01. Except, it doesn't. At least it doesn't show like it does.
You can see in the second image the x values are a bit odd. At first I thought I could circumvent it if I coupled the 'y' data of the function with the iterations of the x data in an array, and then hookt that array up with the graph. That however didn't work out too well:
Maybe it is now just pushing arrays of 2 elements (one x and one y) into the graph and then it directly plots it. So I tried putting the graph outside of the loop. That didn't work either.
Maybe it's something different, I thought. Maybe if I supply it as a cluster:
You can see this isn't working out either.
It should look like this:
I am looking at the calculations the program makes, but they should be fine. Or are they? Am I overlooking again something very basic here? How can I plot it normal?
04-02-2014 04:28 AM - edited 04-02-2014 04:28 AM
Hey Choisai,
The Charts can't take random x values as you are providing.. Or let me put it this way, you can't specify the x values explicitely for the chart. You can specify the 'dt' and intial value though.. So for your application, you can try using an XY graph where you can build the X and Y values into a cluster (use bundle function) and then wire it to the XY graph and you will see the expected x axis values.
regards,
Nitzz
(Give Kudos To Good Answers, Mark it as a Solution If your Problem was Solved )
04-02-2014 04:45 AM
I tried that, but the XY graph can only take a 1D array of a cluster of 2 elements, as can be seen here:
This could easily be solved by turning it into an array using the 'build array' function
However, running this gives me an empty graph.
I tried using the 'max X plot', which should give the 'end value' for X, but that didn't work either.
Running it normally gives me nothing, neither does the 'run continuously' function.
If I look at the X-axis I don't see the numbers I am supposed to see. It is better than the extremely large numbers I previously had, but it's not right. Am I doing it right? Or again something horribly wrong?
Thank you for your support and help so far!
04-02-2014 05:04 AM
Hey Choisai,
You are almost there.. 🙂 Bring the graph outside4 the while loop and build the data into an array inside the loop. Outside the loop take out the built array and bundle the two columns/rows into a cluster and pass it to the XY graph. Sorry that i missed to mention this in my previous post.. Check the attached vi to see an example
regards,
Nitz
(Give Kudos To Good Answers, Mark it as a Solution If your Problem was Solved )
04-02-2014 05:43 AM
I tried, but failed:
Trying it without the 0 and 1 doesn't work either. What is going on?
04-02-2014 06:47 AM
Hey Choisal,
I think you paid a little less attention on the vi I posted.:) I can see that you have missed to enable auto indexing on the arrays terminal connected to the while loop output. Right click the output node where the array is wired and select auto index option. Then you will see that the array coming out of the while loop will be a 2d array instead of 1D and you wont fail this time.. 🙂
regards,
Nitzz
(Give Kudos To Good Answers, Mark it as a Solution If your Problem was Solved )
04-02-2014 07:25 AM
And it works! Thank you so much. It works now and it does exactly what I want. Thank you!