I am getting this error "Assignment has more non-singleton rhs dimensions than non-singleton subscripts". Please help. Mw, Cw and Kw are 243X243 matrices.
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
t_init = 0; t_final = 3;
t_incr = 0.005;
n = (t_final-t_init)/t_incr;
tt = t_init:t_incr:t_final;
trange = [t_init t_final];
F(1,:) = 0*tt;
F(2,:) = 0*tt;
omega = pi/.29;
F(243,:) = 50*sin(omega*tt);
for j = 1:n
pulse(j) = sin(omega*tt(j));
if tt(j) > pi/omega
pulse(j) = 0;
end
end
F(243,1:n) = 50*pulse;
x0=zeros(1,243);
xd0=zeros(1,243);
%newwmark betta method
% M, C, K are matrices multiplying xddot, xdot and x repectively
% F is column vector of exciations. x0, xd0 are initial x0 and xd vectors
tspan = [t_init t_final]; %n is tspan/t_increment
dt = (tspan(2)-tspan(1))/n;
tp(1) = tspan(1);
x(:,1) = x0'; --------------------ERROR LINE--------------------------------------------- THIS IS THE ERROR LINE----------------------------ERROR LINE---------------------------------
xd(:,1) = xd0';
gamma = 1/2; beta = 1/4;
A = (1/(beta*dt^2))*Mw+(gamma/(beta*dt))*Cw+Kw; invA = inv(A);
xdd(:,1) = inv(Mw)*(F(:,1)-Cw*xd(:,1)-Kw*x(:,1));
for i = 1:n
B = (F(:,i+1)+Mw*((1/(beta*dt^2))*x(:,i)+(1/(beta*dt))*xd(:,i)+(1/(2*beta)-1)*xdd(:,i))+Cw*((gamma/(beta*dt))*x(:,i)+(gamma/beta-1)*xd(:,i)+(gamma/beta-2)*(dt/2)*xdd(:,i)));
x(:,i+1) = invA*B;
xdd(:,i+1) = (1/(beta*dt^2))*(x(:,i+1)-x(:,i))-(1/(beta*dt))*xd(:,i)-((1/(2*beta))-1)*xdd(:,i);
xd(:,i+1) = xd(:,i)+(1-gamma)*dt*xdd(:,i)+gamma*dt*xdd(:,i+1);
tp(i+1) = tp(i)+dt;
end
x = x';
x1 = 1000*x;
figure(1), plot(tp,x1(:,1),'k',tp,x1(:,2),'k',tp,x1(:,3),'k',tp,0*tp,'k')
xlabel('Time, s')
ylabel('x, mm')
axis([0 3 -5 10])
hold on
figure(1), plot(tt(1:60),5*pulse(1:60),'.k')
hold off
[t,x2] = ode45('f10',t_init:t_incr:t_final,[0 0 0 0 0 0]);
x2 = 1000*x2;
d(:,1) = (x1(:,1)-x2(:,1));
d(:,2) = (x1(:,2)-x2(:,2));
d(:,3) = (x1(:,3)-x2(:,3));
figure(2), plot(tp,d(:,1),'k',tp,d(:,2),'k',tp,d(:,3),'k',tp,0*tp,'k')
xlabel('Time, s')
ylabel('Difference, mm')
axis([0 3 -1e-2 1e-2])
0 comentarios
Respuestas (1)
Alan Stevens
el 8 de En. de 2021
It gets past your indicated Error line for me, but fails because you haven't defined Mw, Cw or Kw.
0 comentarios
Ver también
Categorías
Más información sobre Solar Power en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!