definision of string variables's dimension

1 vue (au cours des 30 derniers jours)
som
som le 20 Jan 2012
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,

Réponse acceptée

Walter Roberson
Walter Roberson le 20 Jan 2012
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.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by