if else in for loop+looping through line colors for plot
이전 댓글 표시
I'm reading a set of files and setting my plotting characteristics. When I get to a certain number of variables, 15 in this case I run out of regular RGB colors, other than yellow and black. I am using another variable later on in my script as black and yellow is just hard to see. I'm trying to add in additional colors in my loop but I get the index exceeds matrix dimensions error.
This is due to the fact that i is at 16, but I only have 15 total additional Line styles and 5 additional colors. How do I get it to continue going through the files but just start at the beginning of the other LineStyles and extraLineColor variables to continue plotting other lines styles/colors?
Here's my code:
% % %load in files
[files]= dir('*.median.stat');
% %Set plotting characteristics
lWidth = 2;
extraLineColors={rgb('orange') rgb('purple') rgb('DarkGray') rgb('Pink') rgb('Brown')};
LineStyles = {'--' ':' '-' '--' ':' '-' '--' ':' '-' '--' ':' '-' '--' ':' '-'};
stationLineStyles = {'r--' 'r:' 'r-' 'b--' 'b:' 'b-' 'g--' 'g:' 'g-' 'm--' 'm:' 'm-' 'c--' 'c:' 'c-'};
labelSize = 14;
titleSize = 16;
if (i <= 15)
semilogx(files(i).data(:,1),files(i).data(:,2), stationLineStyles{i},'LineWidth',lWidth)
hold on
else (i > 15) semilogx(files(i).data(:,1),files(i).data(:,2),'LineStyle',LineStyles{i},'Color',
extraLineColors{i},'LineWidth',lWidth)
legendn{i} = [sta ' ' loc ' ' chan];
end
end
I know I am probably doing something really silly here or am just tired. Can anyone clue me into to what I'm doing wrong?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Blue에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!