필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How do I add a loops output to an existing array as a new row?

조회 수: 2 (최근 30일)
Elias Beaini
Elias Beaini 2018년 2월 7일
마감: MATLAB Answer Bot 2021년 8월 20일
I have to write a for loop that loops through the columns of an array A and finds the distance of each column from the origin (where the entry in the first row is the x coordinate, the 2nd row is the y coordinate, and the third row is the z coordinate). I have that loop written. But I need to add the solutions of the loop to the Array A as a 4th row and I can't figure it out. Here's what I have so far:
B=[]; n=1:20;
for col=1: length(A(3,n))
dist=sqrt((A(1,n)).^2+(A(2,n)).^2+(A(3,n)).^2);
B=[A, dist];
end

답변 (0개)

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by