Hi.
I don't know how to solve this. I have this code
for i= 1:19
[x(i),y(i),z(i)] = multilaterasi(Reader(1, 1), Reader(1, 2), Reader(1, 3), Distance(1,i), Reader(2, 1), Reader(2, 2), Reader(2, 3), Distance(2,i), Reader(3, 1), Reader(3, 2), Reader(3, 3), Distance(3,i), Reader(4, 1), Reader(4, 2), Reader(4, 3), Distance(4,i));
end
I want to calculate the MSE from that code below with this formula.
MSE = sqrt((x(i)-xa)^2+(y(i)-1)^2+(z(i)-1.5)^2)
x(i), y(i), and z(i) should looping with for 1:19. But xa should looping with step 2 (the result should be 2,4,6,8,10,12 until 38). For example:
MSE = sqrt((x(1)-2)^2+(y(1)-1)^2+(z(1)-1.5)^2)
MSE = sqrt((x(2)-4)^2+(y(2)-1)^2+(z(2)-1.5)^2)
MSE = sqrt((x(3)-6)^2+(y(3)-1)^2+(z(3)-1.5)^2)
and the same for the rest until x(19), y(19), z(19) and xa=38
Please help. Thank you

 채택된 답변

Star Strider
Star Strider 2017년 12월 19일

0 개 추천

In your code, ‘x’, ‘y’, and ‘z’ are vectors. You do not need a loop, since MATLAB uses vectorised operations and will do this automatically.
This works:
MSE = sqrt((x-xa).^2+(y-1).^2+(z-1.5).^2);
Here, since the argument vectors are row vectors, ‘MSE’ will be a row vector the same size as the argument vectors.

댓글 수: 2

Aulia   Pramesthita
Aulia Pramesthita 2017년 12월 19일
oh right thank you
Star Strider
Star Strider 2017년 12월 19일
My pleasure.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

태그

질문:

2017년 12월 19일

댓글:

2017년 12월 19일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by