Hello
I am trying to make a table that looks like this
_____x_____y____z
1
2
3
4
but i get 3 results for every loop, and i therefore dont know how to put them together

 채택된 답변

KL
KL 2017년 4월 26일
편집: KL 2017년 4월 26일

2 개 추천

Hey, you need to save the values inside for loop. You can do it either by creating a bigger x matrix with n rows and 3 columns so you can finally use table(x) to create a table or you can add rows to a predefined table inside the for loop.
T = table;
for n = 1:10
x = P*x+q;
x_t = table(x(1),x(2),x(3));
T = [T; x_t];
end
T.Properties.VariableNames = {'x' 'y' 'z'};

댓글 수: 3

Gabor
Gabor 2019년 3월 4일
not working:
Index exceeds matrix dimensions.
Sunil Verma
Sunil Verma 2020년 12월 9일
편집: Sunil Verma 2020년 12월 9일
Thanks KL sir, I got solution from your code segment. I am trying since two days. finally I reach on solution. thankyou very much
Deepmala Ray
Deepmala Ray 2022년 1월 2일
thank you so much for this section of code....it helped alot

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

추가 답변 (1개)

safi khan
safi khan 2020년 1월 4일

0 개 추천

To Make a Table in MATLAB on for Loop.
Here is the code of Tabe 5.
for a= 1:10
b=a*5
end

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

태그

질문:

2017년 4월 26일

댓글:

2022년 1월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by