I'm plotting a number of variables, say x,y,z
in Matlab (there are plenty of them in the real code...). Just to avoid any stupid mistakes, is there anything like in Stata where you can define a list of local variables and using loop to plot for each variable of the list? For example
local varlist "x y z"
local n: word count `varlist'
local i=1
while `i'<=`n' {
local var: word `i' of `varlist'
hist `var'
local i=`i'+1
}
Plotting in Stata seems implausible, as the data has multi-dimensions. Thanks for your thoughts!
foreach v of varlist x y z { hist `v' }
. (Adjust to multiple lines, as comments don't allow block code). - Roberto Ferrerforeach v in x y z
will work too. - Nick Cox