# one thing i need to know

2 views (last 30 days)
ar fa on 2 Apr 2015
Commented: Star Strider on 3 Apr 2015
hello I am c# programmer. after coding using matlab, I was faced with a problem. I can't convert below c# codes to matlab:
public double[][] Transpose(double[][] M)
{
double[][] R = new double[M.Length][];
for (int c = 0; c < M.Length; c++)
R[c] = new double[M.Length];
for (int i = 0; i < M.Length; i++)
{
for (int j = 0; j < M.Length; j++)
{
R[j][i] = M[i][j];
}
}
return R;
}
Please Help me to convert this code to matlab code and not recommend to use matlab function. Thanks

ar fa on 3 Apr 2015
Edited: James Tursa on 3 Apr 2015
I find solution for creating dynamic array in matlab:
How to Create it:
x = {zeros(1,30);zeros(1,20);zeros(1,10)};
x{4} = x;
How to Access it:
Write:
x{4}{1}(25) = 5;
x{4}{1}
Good luck
##### 2 CommentsShowHide 1 older comment
Star Strider on 3 Apr 2015
... and that’s the one thing ‘ar fa’ needs to know.
Now, a universal polymath!

James Tursa on 2 Apr 2015
Edited: James Tursa on 2 Apr 2015
R = M'
Or if you want to strictly transpose for complex arguments as well,
R = M.'
Stephen23 on 3 Apr 2015
The second, non-conjugate transpose is the correct answer.

Andrew Newell on 2 Apr 2015
For your specific problem, some useful pages are Matrix Indexing in MATLAB, Loop Control Statements and Create Functions in Files. But you seem to be starting from zero knowledge of MATLAB, so you really should start with a tutorial. It wouldn't do you much good if we simply converted your function to MATLAB because you wouldn't know what to do with it.