one thing i need to know

조회 수: 1(최근 30일)
ar fa
ar fa 2015년 4월 2일
댓글: Star Strider 2015년 4월 3일
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[0].Length][];
for (int c = 0; c < M[0].Length; c++)
R[c] = new double[M.Length];
for (int i = 0; i < M.Length; i++)
{
for (int j = 0; j < M[0].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
ar fa 2015년 4월 3일
편집: James Tursa 2015년 4월 3일
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;
Read:
x{4}{1}
Good luck
  댓글 수: 2
Star Strider
Star Strider 2015년 4월 3일
... and that’s the one thing ‘ar fa’ needs to know.
Now, a universal polymath!

댓글을 달려면 로그인하십시오.

추가 답변(2개)

James Tursa
James Tursa 2015년 4월 2일
편집: James Tursa 2015년 4월 2일
R = M'
Or if you want to strictly transpose for complex arguments as well,
R = M.'
  댓글 수: 3
Stephen23
Stephen23 2015년 4월 3일
The second, non-conjugate transpose is the correct answer.

댓글을 달려면 로그인하십시오.


Andrew Newell
Andrew Newell 2015년 4월 2일
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.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by