Unable to perform assignment because the left and right sides have a different number of elements.
조회 수: 1 (최근 30일)
이전 댓글 표시
Constantinos Yiannakis
2019년 12월 11일
댓글: Constantinos Yiannakis
2019년 12월 11일
Error Message
Unable to perform assignment because the left and right sides have a different number of elements.
Error in test5 (line 24)
h1New(c) = ((VFull - discharge)/al(c));
%constants
d = 7.2;
al = 11500;
cd = 0.8;
ct = 0.5;
g = 9.807;
p = 1029;
%Area Of turbine = pi*r^2
A = 40.715;
%Variables that need to change after every loop
h1 = 14.05; %h1 should be replaced with h1New after every 1 loop
h2 = Height(4851:21600,:); %this data is from a data excel sheet
VFull = 161575; %VFull shoule be replaced by NewVolume after every 1 loop
for c=1:16749 %loop needs to be repeated 16759 times
%Discharge
discharge(c) = cd*A*(sqrt(2*g*((abs(h1-h2(c)))))) ;
V = discharge(c)/A;
%Power
Power = (1/2)*ct*p*A*V^3;
%New Volume Calculation
NewVolume(c) = VFull - discharge(c);
VFull=NewVolume(c);
%New h1
h1New(c) = ((VFull - discharge)/al(c));
h1=h1New(c);
end
댓글 수: 0
채택된 답변
meghannmarie
2019년 12월 11일
So you are insexing al by c (al(c)), but al is a constant so only has one element. This should fail on loop 2. Did you mean:
h1New(c) = ((CFull - discharge)/al);
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!