Matlab - problemas de index exceeds matrix dimensions

 
Vista:
sin imagen de perfil
Val: 4
Ha aumentado su posición en 48 puestos en Matlab (en relación al último mes)
Gráfica de Matlab

problemas de index exceeds matrix dimensions

Publicado por Ivan (3 intervenciones) el 14/07/2018 00:19:34
una consulta, como puedo evaluar la funcion polinomica obtenida si me tirra error" indeex exceeds matrix dimensions" cuando la evaluo en 0.05 y 2.03


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
grado=length(tiempo);
b(1:grado)=0;
tiempo(1)=0.5;amplitud(1)=2.99250;
tiempo(2)=1.0;amplitud(2)=0.42340;
tiempo(3)=1.5;amplitud(3)=2.75480;
tiempo(4)=3.5;amplitud(4)=27.4355;
 
f_x1_x0=(amplitud(2)-amplitud(1))/(tiempo(2)-tiempo(1));
f_x2_x1=(amplitud(3)-amplitud(2))/(tiempo(3)-tiempo(2));
f_x3_x2=(amplitud(4)-amplitud(3))/(tiempo(4)-tiempo(3));
f_x2_x1_x0=(f_x2_x1-f_x1_x0)/(tiempo(3)-tiempo(1));
f_x3_x2_x1=(f_x3_x2-f_x2_x1)/(tiempo(4)-tiempo(2));
f_x3_x2_x1_x0=(f_x3_x2_x1-f_x2_x1_x0)/(tiempo(4)-tiempo(1));
 
b0=amplitud(1);
b1=f_x1_x0;
b2=f_x2_x1_x0;
b3=f_x3_x2_x1_x0;
f=@(tiempo) b0+b1*(tiempo-tiempo(1))+b2*((tiempo-tiempo(1)).*(tiempo-tiempo(2)))+b3*((tiempo-tiempo(1)).*(tiempo-tiempo(2)).*(tiempo-tiempo(3)));
plot(tiempo,f(tiempo) , 'r');
grid on;
title('TiempoVSAmplitud');
xlabel('Tiempo');
ylabel('Amplitud');
feval(f,0.05);
feval(f,2.03);
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 JESUS DAVID ARIZA ROYETH
Val: 3.309
Plata
Ha mantenido su posición en Matlab (en relación al último mes)
Gráfica de Matlab

problemas de index exceeds matrix dimensions

Publicado por JESUS DAVID ARIZA ROYETH (1818 intervenciones) el 14/07/2018 02:33:49
la función f necesita de entrada un vector con 3 datos así no te dará error :

feval(f,[0.05 5 3])

sin embargo si le pones ; a esas dos últimas líneas pierden el sentido al menos que las guardes en alguna variable
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
sin imagen de perfil
Val: 4
Ha aumentado su posición en 48 puestos en Matlab (en relación al último mes)
Gráfica de Matlab

problemas de index exceeds matrix dimensions

Publicado por Ivan (3 intervenciones) el 14/07/2018 03:08:36
muchas gracias bro, pero lo que intenete hacer . y me resulto, aunque muy engorroso fue hacer que matlab calculara las constantes a b c y d del polinomio y evaluarlo:

1
2
3
4
5
6
7
8
d=b0-b1*tiempo(1)+b2*tiempo(1)*tiempo(2)-b3*tiempo(1)*tiempo(2)*tiempo(3);
c=b1-b2*tiempo(2)-b2*tiempo(1)-b3*tiempo(1)*tiempo(2)+b3*tiempo(3)*tiempo(2)+b3*tiempo(1)*tiempo(3);
b=b2-tiempo(2)*b3-b3*tiempo(1)-b3*tiempo(3);
a=b3;
 
p=[a b c d];
 
polyval(p,0.05)

muchas gracias tu metodo es mucho mas simple.
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