Matrix dimensions error must agree
조회 수: 7 (최근 30일)
이전 댓글 표시
I don't know why Im having problems doing this problems and I have change everything but still having matrix dimensions. here is my procedure. Thank you.
clc
clear
L=linspace(.4,1.3,3) %1x3
L1=linspace(1,1.5,3) %1x3
L2=linspace(.35,2.8,3) %1x3
L3=linspace(.87,2.4,3) %1x3
W2=linspace(100,300,4)%1x3
W3=linspace(150,400,4)%1x3
W4=linspace(120,300,4)%1x3
h1=linspace(1,2.2,3)%1x3
h2=linspace(.654,1.52,3)%1x3
theta=linspace(11,42,3)
alpha=linspace(42,76,3)
NE=linspace(10,24,3)
F1=linspace(450,1653,3)
[L,W2]=meshgrid(L,W2);
[L1,W3]=meshgrid(L1,W3);
[L2,W4]=meshgrid(L2,W4);
[F1,alpha]=meshgrid(F1,alpha);
[h1,h2]=meshgrid(h1,h2)
[NE,theta]=meshgrid(NE,theta)
figure(1)
W1=(2.*L.*F1.*cos(alpha)-(L-L2).*W2-L.*W3-(L-L3).*W4+(h1+h2).*sin(theta)+(L-(2.*L3)).*NE.*cos(theta)./L1);
댓글 수: 1
Rik
2018년 10월 11일
Today I formatted your code, next time, use the {}Code button. See here for a GIF showing how to do it.
답변 (1개)
Rik
2018년 10월 11일
If you edit your calls to linspace where you ask for a 4-element vector, the code exits without error. Since your code is a bit light on comments I can't tell you if it now actually does what it should do.
As a note: in debugging settings, use clearvars instead of clear or clear all. Outside of debugging, don't use either, but use functions to keep your workspace clean.
clc
clearvars
L=linspace(.4,1.3,3) %1x3
L1=linspace(1,1.5,3) %1x3
L2=linspace(.35,2.8,3) %1x3
L3=linspace(.87,2.4,3) %1x3
W2=linspace(100,300,3)%1x3
W3=linspace(150,400,3)%1x3
W4=linspace(120,300,3)%1x3
h1=linspace(1,2.2,3)%1x3
h2=linspace(.654,1.52,3)%1x3
theta=linspace(11,42,3)
alpha=linspace(42,76,3)
NE=linspace(10,24,3)
F1=linspace(450,1653,3)
[L,W2]=meshgrid(L,W2);
[L1,W3]=meshgrid(L1,W3);
[L2,W4]=meshgrid(L2,W4);
[F1,alpha]=meshgrid(F1,alpha);
[h1,h2]=meshgrid(h1,h2)
[NE,theta]=meshgrid(NE,theta)
W1=(2.*L.*F1.*cos(alpha)-(L-L2).*W2-L.*W3-(L-L3).*W4+(h1+h2).*sin(theta)+(L-(2.*L3)).*NE.*cos(theta)./L1);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 File Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!