Unable to perform assignment because the left and right sides have a different number of elements.
조회 수: 1 (최근 30일)
이전 댓글 표시
im trying to create a matrix from the output of each iteration (h1) where h1 changes each time but keep getting this error message
'Unable to perform assignment because the left and right sides have a different number of elements.'
This is my code
%Get time delay and no. of turbines from user
user=input('Enter a delay time from 1 to 20944: ');
N=input('Enter a number of turbines: ');
%initial h1
h1=14.05;
%ch1=change in h1
%nh1=new h1
for i=1:(20944-user)
h2=TideHeight(user+656+i,1);
Q=Cd*N*(pi*(d/2)^2)*(sqrt(2*g*(h1-h2)));
ch1=Q/A1;
nh1=(h1-ch1);
h1(i)=nh1
end
댓글 수: 0
채택된 답변
Navya Seelam
2019년 12월 9일
Hi,
While calculating Q you are using h1 rather than an element in h1 vector . Hence size of ch1and consequently nh1 which are dependent on Q is not 1x1 as i increases. Thus the assignment h1(i)=nh1 throws error as the size of h1(i) is 1x1 where as the size of nh1 is not 1x1
댓글 수: 0
추가 답변 (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!