Clear Filters
Clear Filters

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

1 view (last 30 days)
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

Accepted Answer

Navya Seelam
Navya Seelam on 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

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!