macro in matlab for incomplete syntax

12 visualizaciones (últimos 30 días)
jingwei chen
jingwei chen el 4 de Feb. de 2022
Comentada: jingwei chen el 20 de Feb. de 2022
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 comentarios
jingwei chen
jingwei chen el 20 de Feb. de 2022
Sorry for responding so late.
I had some practical usage in the past in STATA, but recently i start to learn matlab and want to do same thing in it, that is why i ask.
What do i want to do exactly? Almost everything.
I can tell that you are a matlab expert. You are so familiar with certain function when you need it. so you dont have inner desire to persue such "flexibility", while noob like me does.
I am sure you dont have time to look my STATA do file. But I post one of the many "what i want to do" question for matlab, which is relevent to this and can be achieve by this. Hope you can have a look.@Rik
jingwei chen
jingwei chen el 20 de Feb. de 2022
https://www.mathworks.com/matlabcentral/answers/1654015-create-variables-name-in-pattern?s_tid=srchtitle

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Historical Contests en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by