macro in matlab for incomplete syntax
显示 更早的评论
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 个评论
Rik
2022-2-4
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
2022-2-4
Rik
2022-2-5
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
2022-2-20
jingwei chen
2022-2-20
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Historical Contests 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!