structure

1 visualizzazione (ultimi 30 giorni)
developer
developer il 12 Set 2011
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 Commenti
developer
developer il 13 Set 2011
Yes it works now thanks alot :)
Fangjun Jiang
Fangjun Jiang il 13 Set 2011
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

Accedi per commentare.

Risposta accettata

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

Accedi per commentare.

Più risposte (1)

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

Categorie

Scopri di più su Structures in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by