definision of string variables's dimension
조회 수: 1 (최근 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!