How can I fix the error: Index exceeds the number of array elements (1)?
Mostrar comentarios más antiguos
I am trying to plot a gragh of the eqution below when there is a relation between N_k, t, t_j. The relation is that N_k is the integer of t/tt.(when I define t_j=tt*N_k)
I'm confused how I can get the each value when t is changing within the range and apply the effects on the other components. I tried use array and matrix with 'for', but I getting an error 'Index exceeds the number of array elements (1)'. How can I fix it? Also, is this a right solution to solve this equation? Any comment will be helpful, thank you.

code:
clear
B_n = -5.36;
omega_d = 400;
zeta = 29;
tt=0.01;
upTo_t=10;
total = zeros(upTo_t*100, 1);
for i=1:upTo_t*100
t=0.01*i;
T=t/tt;
N_k=floor(T);
points = zeros(1, N_k);
for j=1:N_k
t_j= tt*j;
points(i,j) = exp(-(zeta/2).*(t(i)-t_j(j))).*(-zeta*(sin(omega_d/2.*(t(i)-t_j(j))))+ omega_d.*cos(omega_d/2*(t(i)-t_j(j))));
end
total(i,1) = B_n/omega_d.*sum(points(i,j));
end
plot(t, total)
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Matrix Indexing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!