definision of string variables's dimension
4 ビュー (過去 30 日間)
古いコメントを表示
Dear.Roberson
Thanks for your tips on decreasing of the program runtime through the definition of variable's dimensions.
I revised my program by making variable's dimensions, but the runtime didn't change.
Can you tell me what the problem is?
I also have another question:
How can I define the dimension of string variables at the begining of the program.
for example: in the program below "normality(j)" is a string variable and I want to define the dimension of this variables at the begining of the program. How can I do it?
for j=1:num_col test_normal(j)=lillietest(q(:,j));
if test_normal(j)==0
normality(j)={'OK'};
else
normality(j)={'___'};
q(:,j)= log10(q(:,j));
normality_log(j)=lillietest(q(:,j));
if test_normal(j)==1 && normality_log(j) ==1; num_non_normal=num_non_normal+1; non_normal_ETO=j; end end end
thanks alot,
0 件のコメント
採用された回答
Walter Roberson
2012 年 1 月 20 日
Your normality array is an example of a cell array. You can initialize it as
normality_array = cell(num_col,1);
With regards to runtime, if you are referring to this question, I said that "part of the reason" for slowness was preallocation. Depending on your variable sizes, the cost of memory allocation might not be much compared to other factors.
There may be other improvements that can be made, but that's a topic for the other question.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!