MATLAB Answers

Unable to perform assignment because the left and right sides have a different number of elements.

조회 수: 6(최근 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

로그인 to comment.

채택된 답변

Navya Seelam
Navya Seelam 9 Dec 2019
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

로그인 to comment.

추가 답변(0개)

이 질문에 답변하려면 로그인을(를) 수행하십시오.

제품


Translated by