macro in matlab for incomplete syntax
Show older comments
I wonder if there is a way to create a short cut for incomplete program.( Creating functions can only serve for complete programs, right? )
Like in Stata:
local aa ########
these mean asign the latter apart (########) to former sign (aa) , whatever ######## is, even an incomplete syntax. It could be really really useful.
For a stupid example:
local a valuable1=
local b ^2/4
local c 2
local d =1/4
`a'`c'`b'
it means valuable1=2^2/4=1
if `a'`d' {
valuable2`c'`d'9`b'`b'
}
it means if valuable1=1/4 execute that asign valuable22=1/49^2/4^2/4. In this example, you can see that i create valuable22 by valuable2`c', and asign = to the formula creating 1/49 at the same time by `d'9
Both of 2 example above use ` ' to cite what we need. And those in ` ' can be a incomplete syntax.
Because of being incomplete, we can use the same sets of macro to create many thing easier (not in here, after all just examples)
And it can asign entirely a complete function.It really only depend on what you write at the end of the command local. When syntax become very long, it is very convinient ,such as:
local q ###############################################################################################
local w &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
local e @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
`q' `w' `e' `w' `e' `q' `e' `q' `w'
even
local r `q' `w'
local y `r' `r`q`w`r`r`r`r'''''''
Using macro for asign a new macro, Imagine that !!!
So, how can i perform the same "function" in matlab?
5 Comments
Rik
on 4 Feb 2022
This exact thing could be achieved, but I'm not going tell you with which function, because it is a terrible idea in Matlab.
I think most useful things can be achieved with anonymous functions.
jingwei chen
on 4 Feb 2022
Rik
on 5 Feb 2022
There is no built-in functionality that I know of that would achieve something like this, except for trickery involving eval.
What is it you want to do? I suspect the flexibility you describe can be achieved with anonymous functions. If you have a specific question, feel free to post the link here.
jingwei chen
on 20 Feb 2022
jingwei chen
on 20 Feb 2022
Answers (0)
Categories
Find more on Historical Contests in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!