필터 지우기
필터 지우기

How do I fix this error "In an assignment A(:) = B, the number of elements in A and B must be the same."?

조회 수: 1 (최근 30일)
clc; clear;
%Design Mission PAX = 250;
Cargo = 8000; Range = 7000; %N. Miles DRatio = .9524988; PRatio = .23590495; M = .85; Vapp = 145; %Knots TOFL = 10500; %Feet a = 576.4592054; % Speed of Sound at 35,000 ft, KNOTS
%%%%%%% Values Changed Manually %%%%%%%%% Abreast = 8; % Tested 4 - 8 N_aisle = 1; % Tested 1 & 2 Sweep = 25; % Degrees, Tested: 25, 30, 35, 40 AR = 8; % Tested: 6-9 Airfoil = 1; % Supercritical = 1, Conventional = 2.
% Assuming a Cl value so need a for loop. CL=[.45:.01:.6]; n = length(CL); DelM = zeros(1,n);
syms x for i= 1:n
if Airfoil == 1
DelM(i) = vpasolve((CL(i)==((-2*10^9)*x^6)-((1*10^8)*x^5)-((2*10^6)*x^4)-((2632.1*x^3)+124.37*x^2)-(5.8637*x)+.5475),x,[-.01 .015]);
end
if Airfoil == 2
DelM(i) = vpasolve(CL(i)==(-5.1087*x^2)-(2.9657*x)+.5509);
end
NewDelM=double(DelM);
% M_Crit=(M+.004)
end
There should be 1 DelM value for every CL iteration. This is why I put the constraint on vpasolve to only use a certain solution. I am still not sure why I am getting the following error: "In an assignment A(:) = B, the number of elements in A and B must be the same."
  댓글 수: 1
Alec Carruthers
Alec Carruthers 2018년 4월 5일
clc; clear;
%Design Mission
PAX = 250;
Cargo = 8000;
Range = 7000; %N. Miles
DRatio = .9524988;
PRatio = .23590495;
M = .85;
Vapp = 145; %Knots
TOFL = 10500; %Feet
a = 576.4592054; % Speed of Sound at 35,000 ft, KNOTS
%%%%%%% Values Changed Manually %%%%%%%%%
Abreast = 8; % Tested 4 - 8
N_aisle = 1; % Tested 1 & 2
Sweep = 25; % Degrees, Tested: 25, 30, 35, 40
AR = 8; % Tested: 6-9
Airfoil = 1; % Supercritical = 1, Conventional = 2.
% Assuming a Cl value so need a for loop. CL=[.45:.01:.6]; n = length(CL); DelM = zeros(1,n);
syms x for i= 1:n
if Airfoil == 1
DelM(i) = vpasolve((CL(i)==((-2*10^9)*x^6)-((1*10^8)*x^5)-((2*10^6)*x^4)-((2632.1*x^3)+124.37*x^2)-(5.8637*x)+.5475),x,[-.01 .015]);
end
if Airfoil == 2
DelM(i) = vpasolve(CL(i)==(-5.1087*x^2)-(2.9657*x)+.5509);
end
NewDelM=double(DelM);
% M_Crit=(M+.004)
end

댓글을 달려면 로그인하십시오.

답변 (1개)

Star Strider
Star Strider 2018년 4월 5일
Save ‘DelM’ as a cell array:
DelM{i} = ...
noting the curly braces ‘{}’ denoting a cell array. Then sort it out later.

카테고리

Help CenterFile Exchange에서 Airfoil tools에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by