structure

조회 수: 1 (최근 30일)
developer
developer 2011년 9월 12일
Hello, I have a structure that has got 20 values :
temp_q(j)=struct('ff' ,{temp_Q});
I have something like this
>> temp_q(1,1).ff{1,1}
ans =
0.0046 0.2417
>> temp_q(1,1).ff{2,1}
ans =
0.0844 0.9421
>> temp_q(1,1).ff{3,1}
ans =
0.2599 0.5752
>> temp_q(1,1).ff{4,1}
ans =
0.1818 0.8212
>> temp_q(1,1).ff{5,1}
ans =
0.1450 0.4509
>> temp_q(2,1).ff{1,1}
ans =
0.5499 0.6477
>> temp_q(2,1).ff{2,1}
ans =
0.3998 0.9561
>> temp_q(2,1).ff{3,1}
ans =
0.8693 0.6491
But i want to make it like this label it as
>> temp_q.Q1
ans =
0.0046 0.2417
0.0844 0.9421
0.2599 0.5752
0.1818 0.8212
0.1450 0.4509
>> temp_q.Q2
ans =
0.5499 0.6477
0.3998 0.9561
0.8693 0.6491
Thanks in advance
  댓글 수: 11
developer
developer 2011년 9월 13일
Yes it works now thanks alot :)
Fangjun Jiang
Fangjun Jiang 2011년 9월 13일
Great! Now since the question has been answered. Please consider reading this post for hints on how to ask a better question. Please also accept the question to indicate that the solution is valid. Many of your questions were answered but not accepted.
http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer

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

채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 9월 12일
You mean like this?
temp_Q=1:20;
temp_q=struct('ff',mat2cell(temp_Q,1,repmat(1,20,1)))
  댓글 수: 18
developer
developer 2011년 9월 13일
Please check it again if it makes some sense.
Fangjun Jiang
Fangjun Jiang 2011년 9월 13일
See comments in your question.

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2011년 9월 12일
for K = 1:length(temp_q)
temp_Q.(sprintf('Q%d', K)) = temp_q(K).ff;
end

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by