Unable to perform assignment because the left and right sides have a different number of elements.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Katy Rayner
am 5 Dez. 2019
Beantwortet: Navya Seelam
am 9 Dez. 2019
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 Kommentare
Akzeptierte Antwort
Navya Seelam
am 9 Dez. 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!