Cell value in workspace into a matrix ! HOW?!

1 回表示 (過去 30 日間)
Peyman
Peyman 2012 年 8 月 7 日
Hi, I used CurveFittingToolbox, then made some changes, then used GenerateCode.
Now, when I run the code (close MATLAB,run it again, clean the workspace, run the code) I get the same results. It also prints the coefficients used for calculation(e.g fitting with SumofSine8 has 24 coefficients, a1 b1 c1 a2 ...). Then, these coeficients are shown in workspace as ... (I don't know, cell?!!)
Now, I need to use these calculated coefficients in the rest of the code. (also the calculated e.g. a1 is not showed anywhere!) How can I call them?!?!?!
(for more information:I want to use these calculated coefficients and right this SumofSin8 formula again, extend the period and kind of extrapolate) Here is the link to photo: https://docs.google.com/folder/d/0Bzt6t5PRyt66MHhYN2JVQlpDSlU/edit

回答 (1 件)

Babak
Babak 2012 年 8 月 7 日
編集済み: Andrei Bobrov 2012 年 8 月 8 日
Assuming that the name of the cell is coeffs.
If you want to convert a cell to matrix, do this:
A = zeros(size(coeffs));
for j=1:size(coeffs,1)
for k=1:size(coeffs,2)
A(j,k) = coeffs{j,k}
end
end
  1 件のコメント
Peyman
Peyman 2012 年 8 月 8 日
編集済み: Peyman 2012 年 8 月 9 日
It didn't work.
MATLAB error:
" Subscripted assignment dimension mismatch"
" Error in ... (line ..)
for k=1:size(coeffs,2) A(j,k) = coeffs{j,k};"

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by