How to find distance using loop?
显示 更早的评论
Hi everyone,
I have to find the distance between IRS and users in 3D, for example from IRS 1 to user1, user2, user 3, user 4 and then from IRS 2 to all the users and so on. I have total 4 users and 8 IRS, I found the distances for each one using norm but now I want to find the distances using a loop so how will the loop work? New to using Matlab and I'm a little bit lost with it. Any answers would be appreciated.
%Distance of IRSs from all the users
IRS1U1=norm([3,1.5,1.5]-[6,8,1])
IRS1U2=norm([3,1.5,1.5] - [6,3,1.5])
IRS1U3=norm([3,1.5,1.5] - [6.5,5.5,1.5])
IRS1U4=norm([3,1.5,1.5] - [9,5.5,1.5])
IRS2U1=norm([6,1,1.5]-[6,8,1])
IRS2U2=norm([6,1,1.5] - [6,3,1.5])
IRS2U3=norm([6,1,1.5] - [6.5,5.5,1.5])
IRS2U4=norm([6,1,1.5] - [9,5.5,1.5])
IRS3U1=norm([8.5,1,1.5]-[6,8,1])
IRS3U2=norm([8.5,1,1.5] - [6,3,1.5])
IRS3U3=norm([8.5,1,1.5] - [6.5,5.5,1.5])
IRS3U4=norm([8.5,1,1.5] - [9,5.5,1.5])
IRS4U1=norm([10.4,2,1.5]-[6,8,1])
IRS4U2=norm([10.4,2,1.5] - [6,3,1.5])
IRS4U3=norm([10.4,2,1.5] - [6.5,5.5,1.5])
IRS4U4=norm([10.4,2,1.5] - [9,5.5,1.5])
IRS5U1=norm([3,10.5,1.5]-[6,8,1])
IRS5U2=norm([3,10.5,1.5] - [6,3,1.5])
IRS5U3=norm([3,10.5,1.5] - [6.5,5.5,1.5])
IRS5U4=norm([3,10.5,1.5] - [9,5.5,1.5])
IRS6U1=norm([6,10.5,1.5]-[6,8,1])
IRS6U2=norm([6,10.5,1.5] - [6,3,1.5])
IRS6U3=norm([6,10.5,1.5] - [6.5,5.5,1.5])
IRS6U4=norm([6,10.5,1.5] - [9,5.5,1.5])
IRS7U1=norm([8.5,10.5,1.5]-[6,8,1])
IRS7U2=norm([8.5,10.5,1.5] - [6,3,1.5])
IRS7U3=norm([8.5,10.5,1.5] - [6.5,5.5,1.5])
IRS7U4=norm([8.5,10.5,1.5] - [9,5.5,1.5])
IRS8U1=norm([10.5,9,1.5]-[6,8,1])
IRS8U2=norm([10.5,9,1.5] - [6,3,1.5])
IRS8U3=norm([10.5,9,1.5] - [6.5,5.5,1.5])
IRS8U4=norm([10.5,9,1.5] - [9,5.5,1.5])
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!