Hello, friends.
Today we discuss about different functions available in Python Math Library and how we can call these
in two levels for that purpose.
I just go to my python cell and over here I just first I want to go to my folder as you see, or here
I have my folder.
I just copy the already created edition code.
Just copy and place it over here.
Right now, I just change the name.
Let's see the math.
Okay.
So right now, the name is changed.
And over here in the python cell, I want to call the function p mac.
So just to go to the commands by ten, like deletion by code.
And over here, this is my addition code.
So right now.
I want to just first check in the python cell.
Different functions available in my library.
So first I import.
Math function, then directly available in math.
So just as you see over here, I got the different math functions available in Python math directory.
Okay, so let's say, oh, here, this is exponential.
This is course function.
This is factorial.
This is flow.
And over here, this is log log ten log base to like this power by radians remainder sine ten.
Okay.
So right now I just want to work with different functions.
So let's say I have my result.
Let's say R is equal to zero.
And in this first function I'm using or here is, let's say, my power.
Okay.
The function name is power.
And over here I'm just using only single variable X, and my result is R.
And that is equal to.
The old view.
Power of X.
And right now, I want to return my function, as you see.
So right now, I just print this
brain.
The function are to check the value, and I want to return my function power.
Let's see.
In this case, for the power, I acquired variables.
So X and Y over here.
X, y.
And over here, let's say two days, two, three, two, comma, three.
Control s.
Now run it at all.
Five.
As you see, I got it.
So it is okay right now.
So let's check for another function.
So just delete this.
Just note.
This is okay.
Right now.
Another function, let's say R one is equal to zero.
So I just copy this result and put it over here.
And right now my function is, let's say, sine function.
I put it as I.
And over here, in this case, my variable is single variable.
And I just use math function.
So math not sine because in the directory it is even over here as you sine function is there.
So sine of x is there and I want to return with my R one over here and r1i want to put over here.
So this is my sign of x, it will give me sign of x.
So like this I just copy and place over here my another function let's say over here is radians.
So I just use this.
So in this case, I just go back to my python code.
And over here, in the place of sine, I just put radians.
And over here I want to make function name R a D, and the result is my R too.
I want to call back R to return and over here my r two is equal to zero initial value.
So let's say another function is my
so go back to the directory or here let's say I want to go for square root.
Okay, so I just copy this square root and over here in the place of radians I just put square root
right now r three is there, so r three is there and in this case I'll just use a skew r d let's say
so right now function is ready.
Let's go for some another function also.
Let's see, I want to go for low ten.
Okay, so just copy this log.
I know some value so I just put it over here.
Then copy this function and over here control X and over here math function log ten.
My code is ready.
And over here this is let's say L or G low and the result is for r four or here I also put our code
and in this case over here are three should be zero.
Initial value and are four is also zero.
So my code is ready.
So right now I just save it.
So go back to folder and over here this is my map.
So I just open it.
Control.
And over here.
I just hope we met in this because it will call the python code.
I want to just edit this icon or here in this case, let's say it is functions from the python's just
okay control as this is done right now, go back to the main code.
Let's say I want to just copy this code, put it over here and rename it to the python code by ten math
code.
Let's see.
And in this python math code, just open it.
So I just go to the program and over here I want to just delete this part, control B and I want to
delete this part because I want to vary the function name.
So for that purpose I just create a combo box over here.
And I also know that the different functions available in my system are power sine gradient, square
root and lock.
So let's put these values inside the combo box.
So for that purpose I just added insert power the next sign, the next gradient, the next log, the
next is to are askew.
Ah, so my functions are ready and over here let's say I want to make square root default it operation
make current value default.
So I just copy or connect this function to the function and I want to call the sub v from here.
Just copy this and drag and drop to my
block diagram.
Just connect this control u.
So right now code is ready, so just check for it.
Let's say I want to check for the power first.
So the input value is let's say two days to three, so run it.
So as you see I got the value eight and in the next case I want to check, let's say for the square
root.
For the law.
So in this case, it is not working for that purpose.
I just stop it because as you see, there was an error in executing the specified function.
The python returns the class type where this.
Okay, so stop it.
So let's.
You name it.
And I want to just delete this y function and just check for the value in this case.
Controller's Control dx.
Let's check for this.
What is the value of log two?
It is giving some error or here.
So we have to just make the code.
We have changed the code over here.
So as you see, power is working perfectly in this case.
Something is missing.
I want to import.
So first I want to again change control Z.
Control Z, because I want to put the code same.
So right now I want to import math function over here.
So if math function is not there, these functions will not work properly.
Control s right now.
Just close it.
Go to your lab view and let's say I want to check for the results or the log log do.
Let's check for the square root.
This is x my x value.
Let's check for the power.
There is some error.
Stop it.
So again, I want to open the python code.
Python integration by code.
By Matt I import math function define function return are one or two or three or four.
Let's check for the sine function in the python.
So for that purpose, print
are one and I want to come with sign off, let's say one.
So run it and check the output.
As you see I got the value is OC or here and the same.
I want to go for the gradients.
So print
and over here I want to go with R2.
And over here, let's say radians or 80 or eight.
Let's check right before running it.
I want to save it.
So as you see, when you go to the value of and also so the code is working properly.
So let's say go for print.
Are for and the value for the function low is, let's say ten again.
Run the module, check for the value.
In this case, log ten is equal to one.
The code is working properly.
Python code so control as it is be met.
Close this.
Go to over here.
Let's check the path.
The math is working properly close this right now the combo box contains different functions.
Or here I have x, y and this is my function's function, let's say.
So let's say I want to go for ten and in this case the log of ten.
And if I want to go for power is not working.
Maybe some error controller's math or by python it says or here let's want to delete this control b
let's check for this value controllers.
So let's check for the square root of ten.
It is working because over here only one variable is needed.
So right now SQL is working.
Let's say for low is working.
Radians is working.
Sine function is working.
But the power is not working.
Because in this case, I need two variables.
So in the python you have to create functions for the same variable.
If you want to go for multiple variable in the same function, you have to call another combo works.
Okay.
So for that purpose, I also create another VI.
Okay.
So this is for now.
Thank you.