Can MATLAB define variables like the following pseudo C-like code?
{
int a = 0;
int b, c;
{
int a = 42;
b = a;
}
c = a;
}
What you are trying to do is impossible directly. The good news is that this is probably fine, because it is difficult to read and properly maintain code that has similarly named variables all over the place. The simplest solution would be to rename the variables:
{
int a = 0;
int b, c;
{
int a = 42;
b = a;
}
c = a;
}
would become (in MATLAB):
a = 0;
d = 42;
b = d;
c = a;
If "inner" a
and "outer" a
are doing different things, you will do no harm by giving them different names, and perhaps even save someone a maintenance nightmare later down the line.