Unable to perform assignment because the left and right sides have a different number of elements.
1 次查看(过去 30 天)
显示 更早的评论
function g = untitled(x,y,z,t)
a = [1.2, -0.5, -1.7, 1.7];
b = [2.3, 1.5, 0.8, 1.4];
d = [0.2, 1.8, 1.3, -0.5];
e = [8.9844, 12.6636, 1.6423, 9.927];
c=0.047;
g = zeros(4, 1);
g(1) = (x-a(1)).^2+(y-b(1)).^2+(z-d(1)).^2-(c*(t-e(1))).^2;
g(2)= (x-a(2)).^2+(y-b(2)).^2+(z-d(2)).^2- (c*(t-e(2))).^2;
g(3)= (x-a(3)).^2+(y-b(3)).^2+(z-d(3)).^2- (c*(t-e(3))).^2;
g(4)= (x-a(4)).^2+(y-b(4)).^2+(z-d(4)).^2- (c*(t-e(4))).^2;
end
4 个评论
Walter Roberson
2020-3-8
If your x, y, z, and t are scalar, then your code already works.
>> untitled(1,2,3,4)
ans =
7.91511906641776
3.77419695540336
11.6077207228184
13.022399312239
Srivardhan Gadila
2020-3-14
@Haoang Sun, what do you mean by x,y,z,t are constants?
Clearly the cause of the error is either of x,y,z,t are non-scalars.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 NaNs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!