# I am getting a sparse error in my Matlab code

1 visualizzazione (ultimi 30 giorni)
Virajan Verma il 28 Set 2018
Modificato: madhan ravi il 29 Set 2018
for i=1:9
for j=1:9
D[i][j]=[0] This line
D[1][1]=[E*A]
D(2)(2)=G*Asy
D(3)(3)=G*Asz
D(4)(4)=G*Jt
D(5)(5)=E*Iy
D(6)(6)=E*Iz
D(7)(7)=1/mu*E1*Jt
D(8)(8)=E1*Jd
D(9)(9)=E1*J11
##### 4 CommentiMostra 2 commenti meno recentiNascondi 2 commenti meno recenti
Virajan Verma il 29 Set 2018
Modificato: Walter Roberson il 29 Set 2018
This is the whole program
%%Input file for Mass Matrix
fid=fopen('input3.txt','r');
CharData=char(Data);
fclose(fid);
disp(CharData);
%%Mass Matrix
M=r*A;
M=[M*eye(9)]
%%Input file for D Matrix
fid=fopen('input4.txt','r');
CharData=char(Data);
fclose(fid);
disp(CharData);
%%Rigidity Matrix
for i=1:9
for j=1:9
D[i][j]=[0]
D[1][1]=[E*A]
D(2)(2)=G*Asy
D(3)(3)=G*Asz
D(4)(4)=G*Jt
D(5)(5)=E*Iy
D(6)(6)=E*Iz
D(7)(7)=1/mu*E1*Jt
D(8)(8)=E1*Jd
D(9)(9)=E1*J11
%%Output file for D Matrix
fid=fopen('OUTPUT3.txt','w');
fprintf(fid,'%d\n',D[i][j]);
fprintf(fid,'%d\n',D[1][1]);
fprintf(fid,'%d\n',D(2)(2));
fprintf(fid,'%d\n',D(3)(3));
fprintf(fid,'%d\n',D(4)(4));
fprintf(fid,'%d\n',D(5)(5));
fprintf(fid,'%d\n',D(6)(6));
fprintf(fid,'%d\n',D(7)(7));
fprintf(fid,'%d\n',D(8)(8));
fprintf(fid,'%d\n',D(9)(9));
fclose(fid);
end
end
madhan ravi il 29 Set 2018
Modificato: madhan ravi il 29 Set 2018

Accedi per commentare.

### Risposte (1)

Jishnu Mukherjee il 28 Set 2018
Modificato: James Tursa il 28 Set 2018
if you are trying to fill the D matrix then try something like this
D=zeros(9,9);
for i=1:9
for j=1:9
D(i,j)=0;
end
end
use () braces instead of []
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Particle & Nuclear Physics in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by