Skip to content

Commit

Permalink
Right alignment in all GUIs.
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoRianiUNIPR committed Mar 27, 2023
1 parent eabf370 commit 28b9651
Show file tree
Hide file tree
Showing 5 changed files with 158 additions and 87 deletions.
24 changes: 13 additions & 11 deletions examples/GUIautocorr.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
65 changes: 37 additions & 28 deletions examples/GUIcorr.m
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
%
Expand Down Expand Up @@ -120,7 +120,7 @@
ij=ij+1;
end
end

else
if nargin<3
unweighted=true;
Expand All @@ -136,7 +136,7 @@


if unweighted==true % unweighted standard deviation

sumx=sum(x);
mx=sumx/lenx;
sumy=sum(y);
Expand All @@ -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);
Expand All @@ -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];
Expand All @@ -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);

Expand All @@ -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) '$'];
Expand Down
22 changes: 11 additions & 11 deletions examples/GUIcov.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
42 changes: 21 additions & 21 deletions examples/GUIregress.m
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Loading

0 comments on commit 28b9651

Please sign in to comment.