Unable to perform assignment because the left and right sides have a different number of elements.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Katy Rayner
le 5 Déc 2019
Réponse apportée : Navya Seelam
le 9 Déc 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 commentaires
Réponse acceptée
Navya Seelam
le 9 Déc 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 commentaires
Plus de réponses (0)
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!