diff --git a/examples/GUIautocorr.m b/examples/GUIautocorr.m index f68c5fae9..1c83ebb15 100644 --- a/examples/GUIautocorr.m +++ b/examples/GUIautocorr.m @@ -152,17 +152,19 @@ str=strForSchool(header, corpus, footer); -% note that there is a maximum of string size of 1200 characters for the -% LaTeX interpreter -startIndex=regexp(str,'\cr'); -a=ceil(length(startIndex)/2); -b=a+1; -toinsert=['\cr ' repmat('&',1,length(header)) ' ']; -while length(str) >1150 % 1200 - str=[str(1:startIndex(a)-2) toinsert str(startIndex(b)-1:end)]; - a=a-1; - b=b-1; -end +% % note that there is a maximum of string size of 1200 characters for the +% % LaTeX interpreter +% startIndex=regexp(str,'\cr'); +% a=ceil(length(startIndex)/2); +% b=a+1; +% % toinsert=['\cr ' repmat('&',1,length(header)) ' ']; +% toinsert=['\\ ' repmat('&',1,length(header)) ' ']; +% +% while length(str) >1150 % 1200 +% str=[str(1:startIndex(a)-2) toinsert str(startIndex(b)-1:end)]; +% a=a-1; +% b=b-1; +% end fs=14; dim = [.02 .80 0.1 0.1]; diff --git a/examples/GUIcorr.m b/examples/GUIcorr.m index f20c9f7e9..bf88d5927 100644 --- a/examples/GUIcorr.m +++ b/examples/GUIcorr.m @@ -11,7 +11,7 @@ % probability distribution. In this case, the second input % argument y is not necessary. If x is a table, weighted % correation is computed where the weights are the values inside -% the contingency table. +% the contingency table. % Data Types - vector of doubles or table % % y : vector of numeric data. Vector. @@ -33,7 +33,7 @@ % out = detailed output to compute the index. struct. % Structure containing the following fields. % out.data = table with n+1 rows (where n is the length of x) -% containing what is shown in the GUI. +% containing what is shown in the GUI. % Last row contains the totals. % out.corr = scalar containing the correlation coefficient. % @@ -120,7 +120,7 @@ ij=ij+1; end end - + else if nargin<3 unweighted=true; @@ -136,7 +136,7 @@ if unweighted==true % unweighted standard deviation - + sumx=sum(x); mx=sumx/lenx; sumy=sum(y); @@ -145,19 +145,19 @@ ymmy=y-my; xmmx2=(x-mx).^2; ymmy2=(y-my).^2; - + xmmxymmy=xmmx.*ymmy; numxy=sum(xmmxymmy); header={'i' 'x_i' 'y_i' '(x_i-M_X)' '(y_i-M_Y)' '(x_i - M_X )^2' '(y_i - M_Y)^2' '(x_i-M_X)(y_i-M_Y)'}; - + corpus=[seq, x,y, xmmx, ymmy, xmmx2, ymmy2, xmmxymmy]; - sumxmmx2=sum(xmmx2); + sumxmmx2=sum(xmmx2); sumymmy2=sum(ymmy2); - rxy=numxy/sqrt(sumxmmx2*sumymmy2); + rxy=numxy/sqrt(sumxmmx2*sumymmy2); footer=[NaN sum(x) sum(y) 0 0 sumxmmx2 sumymmy2 numxy]; strtitle='Details of correlation $(corr(x,y))$ calculation'; - + else % weighted correlation w=w(:); n=sum(w); @@ -176,28 +176,37 @@ numxy=sum(xyw); rxy=numxy/sqrt(sumxmmx2*sumymmy2); header={'i' 'x_i' 'y_i' 'w_i' '(x_i-M_X)^2 w_i' '(y_i-M_Y)^2 w_i' '(x_i-M_X)(y_i-M_Y)w_i'}; - + corpus=[seq, x,y,w, xmmx2, ymmy2, xyw]; - + footer=[NaN sum(x) sum(y) n sumxmmx2 sumymmy2, numxy]; strtitle='Details of weighted correlation calculation'; - + end str=strForSchool(header, corpus, footer); -% note that there is a maximum of string size of 1200 characters for the -% LaTeX interpreter -startIndex=regexp(str,'\cr'); -a=ceil(length(startIndex)/2); -b=a+1; -toinsert=['\cr ' repmat('&',1,length(header)) ' ']; -while length(str) >1150 % 1200 - str=[str(1:startIndex(a)-2) toinsert str(startIndex(b)-1:end)]; - a=a-1; - b=b-1; -end +% % note that there is a maximum of string size of 1200 characters for the +% % LaTeX interpreter +% % startIndex=regexp(str,'\cr'); +% startIndex=regexp(str,'\\'); +% a=ceil(length(startIndex)/2); +% b=a+1; +% % toinsert=['\cr ' repmat('&',1,length(header)) ' ']; +% toinsert=['\\ ' repmat('& ',1,length(header)-1) '\\ ']; +% ij=1; +% strbis=str; +% while length(strbis) >1150 % 1200 +% % if ij==1 +% strbis=[str(1:startIndex(a)-2) toinsert str(startIndex(b)-1:end)]; +% ij=ij+1; +% % else +% % str=[str(1:startIndex(a)-2) str(startIndex(b)-1:end)]; +% % end +% a=a-1; +% b=b+1; +% end fs=14; dim = [.02 .80 0.1 0.1]; @@ -209,14 +218,14 @@ annotation('textbox',dim,'FitBoxToText','on','String',str,'Interpreter','latex','FontSize',fs); if unweighted==true -dim = [.56 .88 0.1 0.1]; + dim = [.56 .88 0.1 0.1]; strmean=['\boldmath{$M_X$}= $\frac{' num2str(sumx) '}{' num2str(lenx) '}=' num2str(mx) '\qquad $' ... '\boldmath{$M_Y$}= $\frac{' num2str(sumy) '}{' num2str(lenx) '}=' num2str(my) '$']; else -dim = [.46 .90 0.09 0.09]; + dim = [.46 .90 0.09 0.09]; strmean=['\boldmath{$M_X$}=$\frac{ \sum_{i=1}^n x_i w_i}{\sum_{i=1}^n w_i}$ = $\frac{' num2str(sumxw) '}{' num2str(n) '}=' num2str(mx) '\qquad $' ... - '\boldmath{$M_Y$}=$\frac{ \sum_{i=1}^n y_i w_i}{\sum_{i=1}^n w_i}$= $\frac{' num2str(sumyw) '}{' num2str(n) '}=' num2str(my) '$']; - + '\boldmath{$M_Y$}=$\frac{ \sum_{i=1}^n y_i w_i}{\sum_{i=1}^n w_i}$= $\frac{' num2str(sumyw) '}{' num2str(n) '}=' num2str(my) '$']; + end annotation('textbox',dim,'FitBoxToText','on','String',strmean,'Interpreter','latex','FontSize',fs); @@ -228,7 +237,7 @@ % strfin = text at the end of the GUI if unweighted==true - + strfin=['\boldmath{$corr(x,y)$}=$\frac{\sum_{i=1}^n (x_i-M_X) (y_i-M_Y)}{ \sqrt{\sum_{i=1}^n (x_i-M_X)^2 \sum_{i=1}^n (y_i-M_Y)^2 }}'... '= \frac{' num2str(numxy) '}{\sqrt{' num2str(sumxmmx2) '\times' num2str(sumymmy2) '}}=' ... num2str(rxy) '$']; diff --git a/examples/GUIcov.m b/examples/GUIcov.m index 0d6895451..c469077e5 100644 --- a/examples/GUIcov.m +++ b/examples/GUIcov.m @@ -173,17 +173,17 @@ str=strForSchool(header, corpus, footer); -% note that there is a maximum of string size of 1200 characters for the -% LaTeX interpreter -startIndex=regexp(str,'\cr'); -a=ceil(length(startIndex)/2); -b=a+1; -toinsert=['\cr ' repmat('&',1,length(header)) ' ']; -while length(str) >1150 % 1200 - str=[str(1:startIndex(a)-2) toinsert str(startIndex(b)-1:end)]; - a=a-1; - b=b-1; -end +% % note that there is a maximum of string size of 1200 characters for the +% % LaTeX interpreter +% startIndex=regexp(str,'\cr'); +% a=ceil(length(startIndex)/2); +% b=a+1; +% toinsert=['\cr ' repmat('&',1,length(header)) ' ']; +% while length(str) >1150 % 1200 +% str=[str(1:startIndex(a)-2) toinsert str(startIndex(b)-1:end)]; +% a=a-1; +% b=b-1; +% end fs=14; dim = [.02 .80 0.1 0.1]; diff --git a/examples/GUIregress.m b/examples/GUIregress.m index 3d227b956..68bca0ded 100644 --- a/examples/GUIregress.m +++ b/examples/GUIregress.m @@ -454,27 +454,27 @@ out.R2=R2; end -startIndex=regexp(str,'\cr'); -a1=ceil(length(startIndex)/2); -b1=a1+1; -toinsert=['\cr ' repmat('&',1,length(header)) ' ']; -while length(str) >1150 - str=[str(1:startIndex(a1)-2) toinsert str(startIndex(b1)-1:end)]; - a1=a1-1; - b1=b1-1; -end - -% note that there is a maximum of string size of 1200 characters for the -% LaTeX interpreter -startIndex=regexp(str1,'\cr'); -a1=ceil(length(startIndex)/2); -b1=a1+1; -toinsert=['\cr ' repmat('&',1,length(header1)) ' ']; -while length(str1) >1100 - str1=[str1(1:startIndex(a1)-2) toinsert str1(startIndex(b1)-1:end)]; - a1=a1-1; - b1=b1-1; -end +% startIndex=regexp(str,'\cr'); +% a1=ceil(length(startIndex)/2); +% b1=a1+1; +% toinsert=['\cr ' repmat('&',1,length(header)) ' ']; +% while length(str) >1150 +% str=[str(1:startIndex(a1)-2) toinsert str(startIndex(b1)-1:end)]; +% a1=a1-1; +% b1=b1-1; +% end +% +% % note that there is a maximum of string size of 1200 characters for the +% % LaTeX interpreter +% startIndex=regexp(str1,'\cr'); +% a1=ceil(length(startIndex)/2); +% b1=a1+1; +% toinsert=['\cr ' repmat('&',1,length(header1)) ' ']; +% while length(str1) >1100 +% str1=[str1(1:startIndex(a1)-2) toinsert str1(startIndex(b1)-1:end)]; +% a1=a1-1; +% b1=b1-1; +% end % main figure h=figure('Position',[100 100 1200 700],'Units','normalized','Name','Parameter estimation and fitted values'); diff --git a/utilities/strForSchool.m b/utilities/strForSchool.m index dacf4afac..6c3a5d1d7 100644 --- a/utilities/strForSchool.m +++ b/utilities/strForSchool.m @@ -9,12 +9,26 @@ classes=''; end -FirstLine='$\matrix{ $\boldmath{$'; +% Option which controls how to display the numbers inside the GUI. +% If rightAlignment is true numbers are right aligned else they are +% centered. +rightAlignment=true; + +if rightAlignment==true + FirstLine='$\begin{array}{rrrrrrrr} \\ $\boldmath{$'; +else + FirstLine='$\matrix{ $\boldmath{$'; +end + for i=1:length(header) if i else - LastLine=[LastLine ' \bf ' numi '}$']; + + if rightAlignment==true + LastLine=[LastLine ' \bf ' numi ' \\ \end{array}$']; + else + LastLine=[LastLine ' \bf ' numi '}$']; + end end end str=[FirstLine TableCorpus LastLine]; +if length(str)>1100 + % note that there is a maximum of string size of 1200 characters for the + % LaTeX interpreter + if rightAlignment==true + startIndex=regexp(str,'\\'); + else + startIndex=regexp(str,'\cr'); + end + a=ceil(length(startIndex)/2); + b=a+1; + + if rightAlignment==true + toinsert=['\\ ' repmat('& ',1,length(header)-1) '\\ ']; + else + toinsert=['\cr ' repmat('&',1,length(header)-1) ' ']; + end + strbis=str; + while length(strbis) >1100 % 1200 + strbis=[str(1:startIndex(a)-2) toinsert str(startIndex(b)-1:end)]; + a=a-1; + b=b+1; + end + str=strbis; +end end