Convert this C program into matlab. Please help. Stuck very badly as con[i][j] matrix is showing decimal nos. like 23.33(which is obviously not accepted in indexing in matlab).That error is showing in MG_matrix[con[eltn][i] - 1][con[eltn][j] - 1]

1 回表示 (過去 30 日間)
for (ip=0;ip<9;ip++)
{
Ms3_matrix[i][j]=Ms3_matrix[i][j]+w3(epsilon3)*J*NTM_matrix[i][ip]*N_matrix[ip][j];
Mte3_matrix[i][j]=Ms3_matrix[i][j];
}
for (i = 0; i <27; i++)
{
for (j = 0; j < 27; j++)
{
Mte6_matrix[i][j]=0;
}
}
for (i = 0; i <27; i++)
{
for (j = 0; j < 27; j++)
{
Mte_matrix[i][j]=0;
/* *****************************Total Element Mass Matrix or Local Mass matrix(Kte_matrix)*************************** */
Mte_matrix[i][j]= Mte_matrix[i][j]+Mte3_matrix[i][j]+Mte6_matrix[i][j];
}
}
for (i = 0; i <30; i++)
{
for (j = 0; j <27; j++)
con[i][j]=58*(j/3)+j+2*i+1
}
}
for (i = 0; i <27; i++)
{
for (j = 0; j <27; j++)
MG_matrix[con[eltn][i] - 1][con[eltn][j] - 1] = Mte_matrix[i][j]; (ERROR HERE)
}
  6 件のコメント
Virajan Verma
Virajan Verma 2018 年 11 月 15 日
for ip=1:9 %%DOUBT
Ms3_matrix(i,j)=Ms3_matrix(i,j)+w3(epsilon3)*J*NTM_matrix(i,ip)*N_matrix(ip,j);
Mte3_matrix(i,j)=Ms3_matrix(i,j);
end
for i=1:27
for j=1:27
Mte_matrix(i,j)=0;
end
end
for i=1:27
for j=1:27
Mte6_matrix(i,j)=0;
end
end
for ip=1:27
Mte_matrix(i,j)= Mte_matrix(i,j)+Mte3_matrix(i,j)+Mte6_matrix(i,j);
end
for i=1:30
for j=1:27
conn(i,j)=58*(j/3)+j+2*i+1
end
end
eltn=30;
for i=1:27
for j=1:27
MG_matrix(conn(eltn,i) -1,conn(eltn,j)-1)= Mte_matrix(i,j);
Virajan Verma
Virajan Verma 2018 年 11 月 15 日
Please help me get over this. M stuck in this for the past 10 days. I really need this fixed ASAP

サインインしてコメントする。

採用された回答

Torsten
Torsten 2018 年 11 月 15 日
編集済み: Torsten 2018 年 11 月 15 日
for i=1:30
for j=1:27
conn(i,j) = 58*floor((j-1)/3)+(j-1)+2*(i-1)+1
end
end
for i=1:27
for j=1:27
MG_matrix(conn(eltn,i) ,conn(eltn,j))= Mte_matrix(i,j);
end
end

その他の回答 (1 件)

Virajan Verma
Virajan Verma 2018 年 11 月 16 日
@Torsten. How can i thank you. U have really solved this obstacle i was on since many days. Really appreciate ur skills and thanks for ur time.

カテゴリ

Help Center および File ExchangeFunction Creation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by