How use TalendDate in context variable - talend

Here the image
How can I run this?

You cannot have talend function defined in the contexts. Rather you have to include the functions while calling the context variables.
Create a context having the path --> ttratta
Call the context and append the date function as below,

Related

Collect internal variables of nested functions in matlab

I have a project consisting of multiple nested functions.
For debugging purpose I want to save all internal variables in one way or another, in order to display figures, replay parts of code etc...
I also want to keep this as transparent as possible regarding calculation time.
My first thought was to create a global variable, and store programmatically at the end of each function the inputs and outputs inside the variable as a structure :
globalVariable.nameOfParentfunction_NameOfFunction.nameInput1 = valueInput1;
globalVariable.nameOfParentfunction_NameOfFunction.nameInput2 = valueInput2;
...
globalVariable.nameOfParentfunction_NameOfFunction.nameOutput1 = valueOutput1;
...
Is it possible to use some kind of reflection to get the name and value of inputs/outputs without necessarily parse the file where the function is written?
I found a good but maybe outdated topic about parsing
How do I collect internal signals?
The simple solution is to use save, which will save all variables in the current workspace (the function’s context) to file.
If you want to keep the values in memory, not in a file, you can use names = who to get a list of all variables defined in the current workspace, then use val = eval(names{i}) to get the value of the variable called name{i}.
I would recommend putting all of that in a separate function, which you can call from any other function to store its variables, to avoid repeating code. This function would use evalin('caller',…) to get names and values of variables in the workspace of the calling function.
Note that using eval or evalin prevents MATLAB from optimizing code using its JIT. They also are dangerous to use, since they can execute arbitrary code, however in this case you control what is being executed so that is no a concern.

Variable inside a macro

How do I create variables inside of a macro? I've created a macro library with some macros and now I am trying to figure out how to create a local variable that exists inside a macro for the lifetime of the macro. Perhaps theres a way to store that data somewhere else?
While editing the Macro, use the Inputs collection of the Details panel to create a dummy variable of the required type.
Do not check the By-Ref checkbox.
Leave it unconnected when calling the Macro.
Use the variable like any other variable.
If you are not using latent functions like delay or timeline, use functions instead.
I create function libraries anytime I need code reuse.

Detach anonymous function from file in which it's defined

I am looking for a workaround for the following problem:
Create a script foo.m containing fun = #(x)(x*x)
Run foo. This creates the variable fun.
Delete foo.m
Try running fun(2).
In recent versions of MATLAB (I am using R2019b) this results in an error:
Previously accessible file "foo.m" is now inaccessible.
Somehow, the anonymous function is tied to the file in which it was defined.
Is it possible to somehow "detach" it so that it would continue working even after the file was deleted?
For those curious why I need this, it is for fixing MATLink, the Mathematica/MATLAB interface, for recent versions of MATLAB.
You can use func2str and str2func to construct a new function handle that will work:
more_fun = str2func(func2str(fun));
more_fun(2)
Note that after this, fun can still not be found, but you can also assign to fun directly to make it accessible again.
Edit: just found a (documented) limitation: if the anonymous function uses outside variables, this method will not work, because
Function handles created using str2func do not have access to variables outside of their local workspace or to nested functions. If your function handle contains these variables or functions, MATLAB® throws an error when you invoke the handle.

Using function "Who" within a function in MATLAB

I am using Matlab R2013a and I am trying to use the 'who' function within a function to retrieve a list of variables that begin with a name.
Let's say I have a list of variable in my workspace as follows:
a = 1
a_2 = 2
a_3 = 3
when I run this:
who('a*');
it works fine.
But when I run the same thing inside a function like this:
function someFunction()
who('a*');
end
or
function someFunction()
disp(who('a*'));
end
It doesn't. No error, just no output.
If I had saved those variables in a Matlab file called
myVariables.mat
and run this within the same function like so:
function someFunction()
who('a*','myVariables');
end
It still doesn't work.
I can understand why the first might not work because of scope, but specifying the file to run the 'who' function on should work... what am I missing?
Any help would be appreciated.
Regards
Diaa
As mentioned by #Daniel, the workspace of a function is separate from the base workspace. There are two ways you could use who inside a m-file to inspect the base workspace:
Use a script instead of a function (i.e. omit the function- line; launch the script by its file name as you do with a function): A script shares the base workspace, and thus, who will be able to see all your variables.
Use evalin: evalin('base','who')
You are trying to access variables within a function. Only the input arguments and global variables are visible within a function. You have to do something like:
function someFunction(a1,a2)
who('a*');
end
If you are really trying to use dynamic variable names, I would strongly recommend to change your design.

MatLab global function issue

I'm learning MatLab & hit a roadblock.
I have an interface.fig file with interface.m which is acting as my 'main' GUI window. From there another file; bright.m is called.
The file bright needs to update global variables in the main file as well as call functions, I have worked out the global variables out but cannot call functions.
Tried everything, looked at doing things like:
reDisplay();
evalin('base','reDisplay()');
interface.reDisplay();
interface>reDisplay();
But had no luck.
Only the first function in an M file is callable from outside of that file. If you want your functions to be globally accessible then you need to save them in independent files.
If you need state to be globally accessible between these functions pass them as arguments or consider using an Object Oriented approach to solving your problem.
If a function in Matlab is defined inside an m-file with file name different than function name - then there is no way of calling this function from outside its m-file.
In order for your reDisplay function to be visible to bright.m, you should have this function in its own m-file called reDisplay.m