Wrong left and right assignment error
古いコメントを表示
Hi there,
I have ellipsoids of different principal radii a b c and within these I attempt to quantify the number of smaller spheres with constant radii that I can fit into the ellipsoids and assess how the number of spheres changes with increasing ellipsoid axes.
The relationship of the counts and the size of the ellipsoids is as follows:
atom counts = 4/3*pi*a*b*c (2/0.0715)
I am still new to matlab and I am struggling to get a proper expression to assess this.
The code below gives the following error:
Unable to perform assignment because the left and right sides have a different number of elements.
a = [3.4995 3.098 2.737 1.9185 2.1555 2.6865 2.0295 2.3715 1.111 2.1575 1.93 1.6605 1.884 1.9795 3.0115 1.2425 2.569 1.8575 1.4275 1.427 2.2905];
b = [2.29 2.807 2.1635 1.6945 1.1335 2.0845 1.7195 2.013 0.9385 1.68 1.7545 0.9175 1.0685 1.029 2.392 0.986 2.1365 1.576 1.0705 1.104 1.882];
c =[2.035 1.295 2.035 1.295 1.295 1.295 1.295 1.295 0.74 1.48 0.925 0.925 1.665 1.11 1.665 0.74 2.035 1.295 0.74 0.555 1.665];
f_pi= 4.1888;
ucellatoms= 2/0.0715;
for n= 1:1:100
l(n) = n.*(a.*b.*c);
Mean_diam(n) =(n.*(a+b+c)./3);
atm_count = ucellatoms.*f_pi.*l;
plot (atm_count,l,'o')
nabc=l';
mean_d = Mean_diam';
atcounts=atm_count';
Ex = [nabc,atcounts];
plot(mean_d,atcounts, '*')
end
採用された回答
その他の回答 (1 件)
Steven Lord
2019 年 12 月 9 日
for n= 1:1:100
l(n) = n.*(a.*b.*c);
When you execute that second line of code, n is a scalar (size 1-by-1.) The variables a, b, and c are 1-by-21 vectors. The result of evaluating n.*(a.*b.*c) is also 1-by-21. You're trying to stuff a 1-by-21 vector into one element of the variable l. That's not going to work; it doesn't fit.
What size do you want / expect the variables l and Mean_diam to be when this code finishes?
1 件のコメント
Arthur Moya
2019 年 12 月 9 日
編集済み: Arthur Moya
2019 年 12 月 9 日
カテゴリ
ヘルプ センター および File Exchange で Surface and Mesh Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!