I’ve been working on an ODE modeling the slipping nature of sand in a cylindrical shell as it rolls down a hill. When I run my code, this error appears:
Error using ==> mrdivide
Matrix dimensions must agree.
Error in ==> sr>f2 at 135
II= (m*a*b*sin(y(1)+alpha)-Iw)/Q+a/J;
Can someone explain to me why this is happening? My initial conditions for this ODE are in a column vector (eg y0 = [PHI;0;0;0];) and I am using ode45 to solve this equation. y0 has been transformed so that it is not confused with a vector (yout = y0.’;). Below is the code(note that the sticking system has no errors):
function sr
global T b My AREA a c h STEEL SAND M m alpha Ic Iw g
tstart = 0;
tfinal = 15;
T=0.05;
b=0.10;
My=2/3*sqrt(T^3*(2*b-T)^3);
AREA= pi*b^2/2-b^2*asin(1-T/b)+(T-b)*sqrt(T*(2*b-T));
a=My/AREA;
c=0.11;
h=0.55;
STEEL=7850;
SAND =1602;
M=pi*(c^2-b^2)*h*STEEL;
m=AREA*h*SAND;
alpha=pi/180*5;
Ic=M/2*(c^2+b^2);
Iw=m*a^2;
g=9.81;
mus=0.5; mud=mus;
PHI=acos((1+M/m)*b/a*sin(alpha));
y0 = [pi/5;0;0;0];
tout = tstart;
yout = y0.’;
teout = [];
yeout = [];
ieout = [];
Q=m*a*sin(y0(1)+alpha)-Ic/b-b*(M+m);
W=Q+m*a*sin(y0(1)+alpha)-Iw/b;
A=1/W*(m*a*g*cos(y0(1)) -(m+M)*b*g*sin(alpha) +m*a*b*y0(2)^2);
PSIDOT=-A/b;
FN=(-A*sin(y0(1)+alpha) — a*PSIDOT + g*cos(y0(1)))/…
(A*cos(y0(1)+alpha) + a*y0(2)^2 + g*sin(y0(1)));
Z= mus-FN;
for i = 1:30
options = odeset(‘Events’,@events2,‘RelTol’,1e-8,‘AbsTol’,1e-12);
if tstart == tfinal
break;
end;
[t,y,te,ye,ie] = ode45(@f2,[tstart tfinal],y0,options);
nt = length(t);
tout = [tout; t(2:nt)];
yout = [yout; y(2:nt,:)];
teout = [teout; te];
yeout = [yeout; ye];
ieout = [ieout; ie];
y0(1) = y(end,1);
y0(2) = y(end,2);
y0(3) = y(end,3);
y0(4) = y(end,4);
tstart = t(nt);
options = odeset(‘Events’,@events1,‘RelTol’,1e-8,‘AbsTol’,1e-12);
if tstart == tfinal
break;
end;
[t,y,te,ye,ie] = ode45(@f1,[tstart tfinal],y0,options);
nt = length(t);
tout = [tout; t(2:nt)];
yout = [yout; y(2:nt,:)];
teout = [teout; te];
yeout = [yeout; ye];
ieout = [ieout; ie];
y0(1) = y(end,1);
y0(2) = y(end,2);
y0(3) = y(end,3);
y0(4) = y(end,4);
tstart = t(nt);
end;
figure(2)
subplot(211)
plot(tout,yout(:,1))
xlabel(‘time’);
ylabel(‘phi’);
subplot(212)
plot(tout,yout(:,2)+yout(:,4)/b)
xlabel(‘time’);
ylabel(‘dphi/dt’);
figure(1)
subplot(211)
plot(tout,yout(:,3))
xlabel(‘time’);
ylabel(‘x’);
subplot(212)
plot(tout,yout(:,4))
xlabel(‘time’);
ylabel(‘v’);
function dydt = f1(t,y)
global b a M m alpha Ic Iw g
Q=m*a*sin(y(1)+alpha)-Ic/b-b*(M+m);
W=Q+m*a*sin(y(1)+alpha)-Iw/b;
A=1/W*(m*a*g*cos(y(1)) -(m+M)*b*g*sin(alpha) +m*a*b*y(2)^2*cos(y(1)+alpha));
PSIDOT=-A/b;
dydt = [-y(4)/b;PSIDOT;y(4);A];
function dydt = f2(t,y)
global b a M m alpha Ic Iw g mud
Q=m*a*sin(y(1)+alpha)-Ic/b-b*(M+m);
J=sin(y(1)+alpha)+mud*cos(y(1)+alpha)*sign(y(2)+y(4)/b);
II= (m*a*b*sin(y(1)+alpha)-Iw)/Q+a/J;
PSIDOT=1/II*((g*cos(y(1))-mud*sign(y(2)+y(4)/b)*(g*sin(y(1))+a*y(2)^2))/J-(m*a*g*cos(y(1))-(m+M)*b*g*sin(alpha)+m*a*b*y(2)^2*cos(y(1)+alpha))/Q);
A=1/Q*(m*a*g*cos(y(1))-(m+M)*b*g*sin(alpha)+m*a*b*y(2)^2*cos(y(1)+alpha)+PSIDOT*(m*a*b*sin(y(1)+alpha)-Iw));
dydt = [y(2);PSIDOT;y(4);A];
function [value,isterminal,direction] = events1(t,y)
global b a M m alpha Ic Iw g mus
Q=m*a*sin(y(1)+alpha)-Ic/b-b*(M+m);
W=Q+m*a*sin(y(1)+alpha)-Iw/b;
A=1/W*(m*a*g*cos(y(1)) -(m+M)*b*g*sin(alpha) +m*a*b*y(2)^2);
PSIDOT=-A/b;
FN=(-A*sin(y(1)+alpha) — a*PSIDOT + g*cos(y(1)))/…
(A*cos(y(1)+alpha) + a*y(2)^2 + g*sin(y(1)));
value = (mus-FN);
isterminal = 1;
direction = 0;
function [value,isterminal,direction] = events2(t,y)
global b
value =y(2)+y(4)/b;
isterminal = 1;
direction = 0;
Содержание
- I am trying to divide and getting the error message «matrix dimensions must agree». What does this mean?
- Direct link to this question
- Direct link to this question
- Answers (1)
- Direct link to this answer
- Direct link to this answer
- Direct link to this comment
- Direct link to this comment
- See Also
- Categories
- Community Treasure Hunt
- How to Get Best Site Performance
- Americas
- Europe
- Asia Pacific
- Error using ==> mrdivide: Matrix dimensions must agree?
- Direct link to this question
- Direct link to this question
- Accepted Answer
- Direct link to this answer
- Direct link to this answer
- More Answers (0)
- See Also
- Categories
- Community Treasure Hunt
- How to Get Best Site Performance
- Americas
- Europe
- Asia Pacific
- I am trying to divide and getting the error message «matrix dimensions must agree». What does this mean?
- Direct link to this question
- Direct link to this question
- Answers (1)
- Direct link to this answer
- Direct link to this answer
- Direct link to this comment
- Direct link to this comment
- See Also
- Categories
- Community Treasure Hunt
- How to Get Best Site Performance
- Americas
- Europe
- Asia Pacific
- Error using ==> mrdivide Matrix dimensions must agree.
- Direct link to this question
- Direct link to this question
- Answers (1)
- Direct link to this answer
- Direct link to this answer
- See Also
- Categories
- Community Treasure Hunt
- How to Get Best Site Performance
- Americas
- Europe
- Asia Pacific
- Error using ==> mrdivide: Matrix dimensions must agree?
- Direct link to this question
- Direct link to this question
- Accepted Answer
- Direct link to this answer
- Direct link to this answer
- More Answers (0)
- See Also
- Categories
- Community Treasure Hunt
- How to Get Best Site Performance
- Americas
- Europe
- Asia Pacific
I am trying to divide and getting the error message «matrix dimensions must agree». What does this mean?
Direct link to this question
Direct link to this question
0 Comments
Answers (1)
Direct link to this answer
Direct link to this answer
1 Comment
Direct link to this comment
Direct link to this comment
See Also
Categories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Читайте также: Pcl xl error subsystem kernel unsupportedprotocol
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 简体中文 Chinese
- English
- 日本 Japanese (日本語)
- 한국 Korean (한국어)
Accelerating the pace of engineering and science
MathWorks is the leading developer of mathematical computing software for engineers and scientists.
Источник
Error using ==> mrdivide: Matrix dimensions must agree?
Direct link to this question
Direct link to this question
0 Comments
Accepted Answer
Direct link to this answer
Direct link to this answer
0 Comments
More Answers (0)
See Also
Categories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 简体中文 Chinese
- English
- 日本 Japanese (日本語)
- 한국 Korean (한국어)
Читайте также: An error occurred during the installation sony vegas
Accelerating the pace of engineering and science
MathWorks is the leading developer of mathematical computing software for engineers and scientists.
Источник
I am trying to divide and getting the error message «matrix dimensions must agree». What does this mean?
Direct link to this question
Direct link to this question
0 Comments
Answers (1)
Direct link to this answer
Direct link to this answer
1 Comment
Direct link to this comment
Direct link to this comment
See Also
Categories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 简体中文 Chinese
- English
- 日本 Japanese (日本語)
- 한국 Korean (한국어)
Accelerating the pace of engineering and science
MathWorks is the leading developer of mathematical computing software for engineers and scientists.
Источник
Error using ==> mrdivide Matrix dimensions must agree.
Direct link to this question
Direct link to this question
0 Comments
Answers (1)
Direct link to this answer
Direct link to this answer
0 Comments
See Also
Categories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
Читайте также: Floating point error domain in с
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 简体中文 Chinese
- English
- 日本 Japanese (日本語)
- 한국 Korean (한국어)
Accelerating the pace of engineering and science
MathWorks is the leading developer of mathematical computing software for engineers and scientists.
Источник
Error using ==> mrdivide: Matrix dimensions must agree?
Direct link to this question
Direct link to this question
0 Comments
Accepted Answer
Direct link to this answer
Direct link to this answer
0 Comments
More Answers (0)
See Also
Categories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 简体中文 Chinese
- English
- 日本 Japanese (日本語)
- 한국 Korean (한국어)
Accelerating the pace of engineering and science
MathWorks is the leading developer of mathematical computing software for engineers and scientists.
Источник
-
Imm
- Пользователь
- Сообщения: 2
- Зарегистрирован: Вт дек 27, 2011 5:51 am
Расчет сигнала(ошибка Error using ==> mrdivide)
Собственно проблема в матрицах.Не могу правильно расставить поэлементное умножение.Может кто свежим взглядом подскажет? А то, честно говоря, уже задолбался читать то «Error using ==> mpower», то «Error using ==> mrdivide»
Код: Выделить всё
b=10;
k=1;
Er=10;
Br=10^-2;
H0=39;
E0=8.85*10^-12;
U0=4*pi*10^-7;
Ne=10^16;
Nu=10^16;
Ge=1.6*10^-19;
Gu=1.6*10^-19;
Me=9.1*10^-31;
Mu=5*10^4*Me;
Ve=10^9;
Vu=Ve/(Mu/Me)^0.5;
Wre=Ge*U0*(H0/Me);
Wru=Gu*U0*(H0/Mu);
Wpe=Ge*(Ne/(Me*E0))^0.5;
Wpu=Gu*(Nu/(Mu*E0))^0.5;
w1=0.9;
f2=0:10^5:10^9;
w2=2*pi*f2;
w3=w2*(10);
E3=Er.*(1+b*k*w1)+((Wpe.^2*w3)/w2).*(1/(Ve.^2+w3.^2))-i*(((Br/(w2*E0))+((Wpe.^2*Ve)/w2)).*(1/(w3.^2+Ve.^2)))+(((Wpu.^2*w3)/w2).*(1/(Vu.^2+w3.^2))-i*(((Br/(w2.*E0))+((Wpu.^2*Vu)/w2)).*(1/(w3.^2+Vu.^2))));
w22=0:1000:10^9;
figure(1);semilogx(w22,real(E3));title('Re(E3)');
p.s. фотография задания
-
vvamy
- Эксперт
- Сообщения: 654
- Зарегистрирован: Ср сен 22, 2004 4:49 pm
Re: Расчет сигнала(ошибка Error using ==> mrdivide)
Сообщение vvamy » Вт дек 27, 2011 8:31 am
E3=Er.*(1+b*k*w1)+((Wpe^2*w3)/w2).*(1./(Ve.^2+w3.^2)…
-i*((Br./(w2*E0))+(Wpe^2*Ve)./w2).*(1./(w3.^2+Ve^2)))…
+(((Wpu.^2*w3)./w2).*(1./(Vu.^2+w3.^2))-i*(((Br./(w2.*E0))…
+((Wpu.^2*Vu)./w2)).*(1./(w3.^2+Vu.^2))));
Далее вычислите w22 так, чтобы w22 и E3 были одинаковой размерности. Тогда сработает и
figure(1);semilogx(w22,real(E3));title(‘Re(E3)’);
Виталий.
-
Imm
- Пользователь
- Сообщения: 2
- Зарегистрирован: Вт дек 27, 2011 5:51 am
Re: Расчет сигнала(ошибка Error using ==> mrdivide)
Сообщение Imm » Вт дек 27, 2011 11:01 am
vvamy писал(а):E3=Er.*(1+b*k*w1)+((Wpe^2*w3)/w2).*(1./(Ve.^2+w3.^2)…
-i*((Br./(w2*E0))+(Wpe^2*Ve)./w2).*(1./(w3.^2+Ve^2)))…
+(((Wpu.^2*w3)./w2).*(1./(Vu.^2+w3.^2))-i*(((Br./(w2.*E0))…
+((Wpu.^2*Vu)./w2)).*(1./(w3.^2+Vu.^2))));Далее вычислите w22 так, чтобы w22 и E3 были одинаковой размерности. Тогда сработает и
figure(1);semilogx(w22,real(E3));title(‘Re(E3)’);
Виталий.
Виталий, благодарю вас от всей души!Радует то, что матлаб график рассчитал без ошибок в ходе подсчета.Насколько корректные данные получились еще не известно, но в любом случае огромное спасибо.
Разъясните в чем ошибка заключалась? Вижу во многих местах нужно было поэлементно умножать или делить. В чем отличие правого от левого деления и почему надо «возведение матрицы в степень», а не «поэлементное возведение матрицы в степень».В общем хотелось бы понять свои ошибки и не допускать их в будущем. Заранее огромное спасибо.