Matlab - problema funcion sparse

 
Vista:

problema funcion sparse

Publicado por alejandro (6 intervenciones) el 29/05/2017 05:08:47
tengo el siguiente error:
Undefined function 'sparse' for input arguments of type 'sym'.

Error in ejercicioviga (line 59)
Kglobal=sparse(f,c,v,n+1,n+1)+Kglobal;

alguien podria decirme en que estoy mal por fis.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
clear
clc
syms  x real
n=4;
L=4;
l=L/n;
elem=[1 2
      2 3
      3 4
      4 5];
nodo=[1
      2
      3
      4];
 
gdl=[2*elem(:,1)-1 2*elem(:,1) 2*elem(:,2)-1 2*elem(:,2)];
%%%%%%%%Funciones de forma%%%%%%%%%%%%%
V=[1 x x^2 x^3];
V_d=diff(V,x);
 
xi=[0 l];
for i=1:2
    x=xi(1,i);
    eval(V);
    eval(V_d);
    P(2*i-1,:)=eval(V);
    P(2*i,:)=eval(V_d);
 
end
%p=length(V);
T=[1 0 0 0
   0 1 0 0
   0 0 1 0
   0 0 0 1];
M=P\T;
N=V*M;
N1=simplify(N(1,1));
N2=simplify(N(1,2));
N3=simplify(N(1,3));
N4=simplify(N(1,4));
%%%%%%%%%Matriz de rigidez local%%%%%%%%%%%%%%%%%%%%%
syms x real
E=1;
I=1;
klocal=E*I*int(diff(N',2)*diff(N,2),x,0,L);%%%%           %N=[N1*N1 N1*N2 N1*N3 N1*N4
                                                          %   N2*N1 N2*N2 N2*N3 N2*N4
                                                          %   N3*N1 N3*N2 N3*N3 N3*N4
                                                          %   N4*N1 N4*N2 N4*N3 N4*N4]

%%%%%%%%%ensamble matriz rigidez global%%%%%%%%%%%%%%

Kglobal=sparse(n+1,n+1);

for i=1:4  
    for j=1:4
f=[gdl(:,i)];
c=[gdl(:,j)];
v=klocal(i,j);
Kglobal=sparse(f,c,v,n+1,n+1)+Kglobal;
    end
end
Full(Kglobal)
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de JOSE JEREMIAS CABALLERO
Val: 6.975
Oro
Ha mantenido su posición en Matlab (en relación al último mes)
Gráfica de Matlab

problema funcion sparse

Publicado por JOSE JEREMIAS CABALLERO (5917 intervenciones) el 31/05/2017 18:01:48
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
clear
clc
syms  x real
n=9;
L=4;
l=L/n;
elem=[1 2
      2 3
      3 4
      4 5];
nodo=[1
      2
      3
      4];
 
gdl=[2*elem(:,1)-1 2*elem(:,1) 2*elem(:,2)-1 2*elem(:,2)];
%%%%%%%%Funciones de forma%%%%%%%%%%%%%
V=[1 x x^2 x^3];
V_d=diff(V,x);
 
xi=[0 l];
for i=1:2
    x=xi(1,i);
    eval(V);
    eval(V_d);
    P(2*i-1,:)=eval(V);
    P(2*i,:)=eval(V_d);
 
end
%p=length(V);
T=[1 0 0 0
   0 1 0 0
   0 0 1 0
   0 0 0 1];
M=P\T;
N=V*M;
N1=simplify(N(1,1));
N2=simplify(N(1,2));
N3=simplify(N(1,3));
N4=simplify(N(1,4));
%%%%%%%%%Matriz de rigidez local%%%%%%%%%%%%%%%%%%%%%
syms x real
E=1;
I=1;
klocal=E*I*int(diff(N',2)*diff(N,2),x,0,L);%%%%           %N=[N1*N1 N1*N2 N1*N3 N1*N4
                                                          %   N2*N1 N2*N2 N2*N3 N2*N4
                                                          %   N3*N1 N3*N2 N3*N3 N3*N4
                                                          %   N4*N1 N4*N2 N4*N3 N4*N4]
 
%%%%%%%%%ensamble matriz rigidez global%%%%%%%%%%%%%%
Kglobal=sparse(n+1,n+1);
for i=1:4
    for j=1:4
f=[gdl(:,i)];
c=[gdl(:,j)];
v=[double(klocal(i,j))];
Kglobal=sparse(f,c,v,n+1,n+1)  +Kglobal;
    end
end
Kglobal
full(Kglobal)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
>> spacer10
Kglobal =
   1.0e+05 *
   (1,1)       3.3584
   (2,1)       0.7244
   (3,1)      -3.3584
   (4,1)       0.7682
   (1,2)       0.7244
   (2,2)       0.1563
   (3,2)      -0.7244
   (4,2)       0.1656
   (1,3)      -3.3584
   (2,3)      -0.7244
   (3,3)       6.7168
   (4,3)      -0.0437
   (5,3)      -3.3584
   (6,3)       0.7682
   (1,4)       0.7682
   (2,4)       0.1656
   (3,4)      -0.0437
   (4,4)       0.3321
   (5,4)      -0.7244
   (6,4)       0.1656
   (3,5)      -3.3584
   (4,5)      -0.7244
   (5,5)       6.7168
   (6,5)      -0.0437
   (7,5)      -3.3584
   (8,5)       0.7682
   (3,6)       0.7682
   (4,6)       0.1656
   (5,6)      -0.0437
   (6,6)       0.3321
   (7,6)      -0.7244
   (8,6)       0.1656
   (5,7)      -3.3584
   (6,7)      -0.7244
   (7,7)       6.7168
   (8,7)      -0.0437
   (9,7)      -3.3584
  (10,7)       0.7682
   (5,8)       0.7682
   (6,8)       0.1656
   (7,8)      -0.0437
   (8,8)       0.3321
   (9,8)      -0.7244
  (10,8)       0.1656
   (7,9)      -3.3584
   (8,9)      -0.7244
   (9,9)       3.3584
  (10,9)      -0.7682
   (7,10)      0.7682
   (8,10)      0.1656
   (9,10)     -0.7682
  (10,10)      0.1758
ans =
   1.0e+05 *
    3.3584    0.7244   -3.3584    0.7682         0         0         0         0         0         0
    0.7244    0.1563   -0.7244    0.1656         0         0         0         0         0         0
   -3.3584   -0.7244    6.7168   -0.0437   -3.3584    0.7682         0         0         0         0
    0.7682    0.1656   -0.0437    0.3321   -0.7244    0.1656         0         0         0         0
         0         0   -3.3584   -0.7244    6.7168   -0.0437   -3.3584    0.7682         0         0
         0         0    0.7682    0.1656   -0.0437    0.3321   -0.7244    0.1656         0         0
         0         0         0         0   -3.3584   -0.7244    6.7168   -0.0437   -3.3584    0.7682
         0         0         0         0    0.7682    0.1656   -0.0437    0.3321   -0.7244    0.1656
         0         0         0         0         0         0   -3.3584   -0.7244    3.3584   -0.7682
         0         0         0         0         0         0    0.7682    0.1656   -0.7682    0.1758

Saludos
JOSE JEREMIAS CABALLERO
Asesor de Proyectos con Matlab
Servicios de programación matlab


http://matlabcaballero.blogspot.com
https://www.facebook.com/matlabcaballero/
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

problema funcion sparse

Publicado por VICTOR (6 intervenciones) el 31/05/2017 18:13:04
ohhhhh gracias estaba bloqueado solo en eso
la otra pregunta para que sirve el comando "double"
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar