Unable to perform assignment because the left and right sides have a different number of elements.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Walter Roberson
am 8 Mär. 2020
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
am 14 Mär. 2020
@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.
Antworten (0)
Siehe auch
Kategorien
Mehr zu NaNs finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!