Syntax error when running matlab code - matlab

I downloaded some matlab code, when trying to run a test file, it ends finding a syntax error, this one here:
parse error near line 151 of file /media/34GB/escola/efficientLBP/pixelwiseLBP.m
syntax error
>>>> [minLBP, ~]=sortNeighbours( binaryWord, weigthVec,...
^
The code it is:
else % if iChan==1 || isChanWiseRot
[minLBP, ~]=sortNeighbours( binaryWord, weigthVec,...
iCircShiftMinLBP(iRow, iCol) );
What is wrong here? Thanks for the time.
P.S: EDITED
Here is the extra code requested:
for iRow=( filtDimsR(1)+1 ):( padImgSize(1)-filtDimsR(1) )
for iCol=( filtDimsR(2)+1 ):( padImgSize(2)-filtDimsR(2) )
subImg=chanImgPad(iRow+( -filtDimsR(1):filtDimsR(1) ),...
iCol+( -filtDimsR(2):filtDimsR(2) ));
% find differences between current pixel, and it's neighours
diffVec=sum(sum( filtR.*repmat(subImg,[1, 1, nNeigh]) ));
diffVec=roundnS(diffVec, nEps);
binaryWord=( diffVec(:)>=0 );
if isRotInv
if iChan==1 || isChanWiseRot % go through all posible binary
% word combination, finding minimal LBP
[minLBP, iCircShiftMinLBP(iRow, iCol)]=...
sortNeighbours(binaryWord, weigthVec);
else % if iChan==1 || isChanWiseRot
[minLBP, ~]=sortNeighbours( binaryWord, weigthVec,...
iCircShiftMinLBP(iRow, iCol) );
end % if iChan==1 || isChanWiseRot
else
minLBP=weigthVec*binaryWord;
end % if isRotInv
currChanLBP(iRow, iCol)=cast( minLBP, outClass); % convert to decimal.
end % for iCol=(1+filtDimsR(2)):(imgSize(2)-filtDimsR(2))
% Present waitbar- a bar with progress, time passed and time remaining
waitbarTimeRemaining(hWaitbar, hTicPixelwiseLBP,...
(( iRow-filtDimsR(1) )+nRows*(iChan-1))/(nClrChans*nRows));
end % for iRow=(1+filtDimsR(1)):(imgSize(1)-filtDimsR(1))

Related

Plotting 3 variables against 1 variable

I have a code that computes the max value. this code consists of four variables www is the function of a,b, and c labaled xx, yy, and zz respectively, so my question is how can i plot www against xx,yy, and zz? Thanks for helping
objfun file
function f=W4qubit(x,a,b,c,d)
c1=-cos(x(1))*(cos(x(5))*(cos(x(9))*(cos(x(13))-cos(x(15)))-cos(x(11))*(cos(x(13))+cos(x(15))))+...
cos(x(7))*(cos(x(11))*(cos(x(15))-cos(x(13)))-cos(x(9))*(cos(x(13))+cos(x(15)))))-...
cos(x(3))*(cos(x(5))*(cos(x(11))*(cos(x(15))-cos(x(13)))-cos(x(9))*(cos(x(13))+cos(x(15))))-...
cos(x(7))*(cos(x(9))*(cos(x(13))-cos(x(15)))-cos(x(11))*(cos(x(13))+cos(x(15)))));
c2=cos(x(1))*(cos(x(5))*(sin(x(9))*(sin(x(13))*cos(x(10)-x(14))-sin(x(15))*cos(x(10)-x(16)))-...
sin(x(11))*(sin(x(13))*cos(x(12)-x(14))+sin(x(15))*cos(x(12)-x(16))))+...
cos(x(7))*(sin(x(11))*(sin(x(15))*cos(x(12)-x(16))-sin(x(13))*cos(x(12)-x(14)))-...
sin(x(9))*(sin(x(13))*cos(x(10)-x(14))+sin(x(15))*cos(x(10)-x(16)))))+...
cos(x(3))*(cos(x(5))*(sin(x(11))*(sin(x(15))*cos(x(12)-x(16))-sin(x(13))*cos(x(12)-x(14)))-...
sin(x(9))*(sin(x(13))*cos(x(10)-x(14))+sin(x(15))*cos(x(10)-x(16))))-...
cos(x(7))*(sin(x(9))*(sin(x(13))*cos(x(10)-x(14))-sin(x(15))*cos(x(10)-x(16)))-...
sin(x(11))*(sin(x(13))*cos(x(12)-x(14))+sin(x(15))*cos(x(12)-x(16)))));
c3=cos(x(1))*(sin(x(5))*(cos(x(9))*(sin(x(13))*cos(x(6)-x(14))-sin(x(15))*cos(x(6)-x(16)))-...
cos(x(11))*(sin(x(13))*cos(x(6)-x(14))+sin(x(15))*cos(x(6)-x(16))))+...
sin(x(7))*(cos(x(11))*(sin(x(15))*cos(x(8)-x(16))-sin(x(13))*cos(x(8)-x(14)))-...
cos(x(9))*(sin(x(13))*cos(x(8)-x(14))+sin(x(15))*cos(x(8)-x(16)))))+...
cos(x(3))*(sin(x(5))*(cos(x(11))*(sin(x(15))*cos(x(6)-x(16))-sin(x(13))*cos(x(6)-x(14)))-...
cos(x(9))*(sin(x(13))*cos(x(6)-x(14))+sin(x(15))*cos(x(6)-x(16))))-...
sin(x(7))*(cos(x(9))*(sin(x(13))*cos(x(8)-x(14))-sin(x(15))*cos(x(8)-x(16)))-...
cos(x(11))*(sin(x(13))*cos(x(8)-x(14))+sin(x(15))*cos(x(8)-x(16)))));
c4=cos(x(1))*(sin(x(5))*(sin(x(9))*cos(x(6)-x(10))*(cos(x(13))-cos(x(15)))-sin(x(11))*cos(x(6)-x(12))*(cos(x(13))+cos(x(15))))+...
sin(x(7))*(sin(x(11))*cos(x(8)-x(12))*(cos(x(15))-cos(x(13)))-sin(x(9))*cos(x(8)-x(10))*(cos(x(13))+cos(x(15)))))+...
cos(x(3))*(sin(x(5))*(sin(x(11))*cos(x(6)-x(12))*(cos(x(15))-cos(x(13)))-sin(x(9))*cos(x(6)-x(10))*(cos(x(13))+cos(x(15))))-...
sin(x(7))*(sin(x(9))*cos(x(8)-x(10))*(cos(x(13))-cos(x(15)))-sin(x(11))*cos(x(8)-x(12))*(cos(x(13))+cos(x(15)))));
c5=sin(x(1))*(cos(x(5))*(cos(x(9))*(sin(x(13))*cos(x(2)-x(14))-sin(x(15))*cos(x(2)-x(16)))-...
cos(x(11))*(sin(x(13))*cos(x(2)-x(14))+sin(x(15))*cos(x(2)-x(16))))+...
cos(x(7))*(cos(x(11))*(sin(x(15))*cos(x(2)-x(16))-sin(x(13))*cos(x(2)-x(14)))-...
cos(x(9))*(sin(x(13))*cos(x(2)-x(14))+sin(x(15))*cos(x(2)-x(16)))))+...
sin(x(3))*(cos(x(5))*(cos(x(11))*(sin(x(15))*cos(x(4)-x(16))-sin(x(13))*cos(x(4)-x(14)))-...
cos(x(9))*(sin(x(13))*cos(x(4)-x(14))+sin(x(15))*cos(x(4)-x(16))))-...
cos(x(7))*(cos(x(9))*(sin(x(13))*cos(x(4)-x(14))-sin(x(15))*cos(x(4)-x(16)))-...
cos(x(11))*(sin(x(13))*cos(x(4)-x(14))+sin(x(15))*cos(x(4)-x(16)))));
c6=sin(x(1))*(cos(x(5))*(sin(x(9))*cos(x(2)-x(10))*(cos(x(13))-cos(x(15)))-sin(x(11))*cos(x(2)-x(12))*(cos(x(13))+cos(x(15))))+...
cos(x(7))*(sin(x(11))*cos(x(2)-x(12))*(cos(x(15))-cos(x(13)))-sin(x(9))*cos(x(2)-x(10))*(cos(x(13))+cos(x(15)))))+...
sin(x(3))*(cos(x(5))*(sin(x(11))*cos(x(4)-x(12))*(cos(x(15))-cos(x(13)))-sin(x(9))*cos(x(4)-x(10))*(cos(x(13))+cos(x(15))))-...
cos(x(7))*(sin(x(9))*cos(x(4)-x(10))*(cos(x(13))-cos(x(15)))-sin(x(11))*cos(x(4)-x(12))*(cos(x(13))+cos(x(15)))));
c7=sin(x(1))*(sin(x(5))*cos(x(2)-x(6))*(cos(x(9))*(cos(x(13))-cos(x(15)))-cos(x(11))*(cos(x(13))+cos(x(15))))-...
sin(x(7))*cos(x(2)-x(8))*(cos(x(11))*(cos(x(15))-cos(x(13)))-cos(x(9))*(cos(x(13))+cos(x(15)))))+...
sin(x(3))*(sin(x(5))*cos(x(4)-x(6))*(cos(x(11))*(cos(x(15))-cos(x(13)))-cos(x(9))*(cos(x(13))+cos(x(15))))-...
sin(x(7))*cos(x(4)-x(8))*(cos(x(9))*(cos(x(13))-cos(x(15)))-cos(x(11))*(cos(x(13))+cos(x(15)))));
A2=2*a*b;
A3=2*a*c;
A4=2*b*c;
A5=2*a*d;
A6=2*b*d;
A7=2*c*d;
f1=c1+A2*c2+A3*c3+A4*c4+A5*c5+A6*c6+A7*c7;
f=-(f1^2);
my main file of the code
clear
close
clc
%x=[x(1),x(2),x(3),x(4),x(5),x(6),x(7),x(8),x(9),x(10),x(11),x(12),x(13),x(14),x(15),x(16)]; % angles;
lb=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
ub=[pi,2*pi,pi,2*pi,pi,2*pi,pi,2*pi,pi,2*pi,pi,2*pi,pi,2*pi,pi,2*pi];
options = optimoptions(#fmincon,'TolX',10^-12,'MaxIter',1500,'MaxFunEvals',10^8,'Algorithm','sqp','TolFun',10^-8);
a=0:0.1:1;
b=0:0.1:1;
c=0:0.1:1;
w=NaN(length(a),length(b),length(c));
ww=NaN(length(a),length(b),length(c));
www=NaN(length(a),length(c));
for k=1:100
x0=rand([1,16]).*ub*.9986;%7976
for i=1:length(a)
for j=1:length(b)
for l=1:length(c)
dhelp=1-(a(i)^2)-(b(j)^2)-(c(l)^2);
if (dhelp>0 || dhelp==0)
d=sqrt(dhelp);
[~,fval]=fmincon(#(x)W4qubit(x,a(i),b(j),c(l),d),x0,[],[],[],[],lb,ub,[],options);
w(i,j,l)=sqrt(-fval);
else
w(i,j,l)=nan;
end
ww=max(w,ww);
end
end
end
end
www=max(ww,[],3);
yy=b.^2;xx=a.^2;zz=c.^2;
meshc(xx,yy,www)
grid on
zlabel('\fontname{Times New Roman} M_{max}')
xlabel('\fontname{Times New Roman}\alpha^2')
ylabel('\fontname{Times New Roman}\gamma^2')
%title('fontname{Times New Roman} Maximum of the Svetlichny operator. Method 1 (alpha|0001>+beta|0010>+gamma|1000>)')
Not sure, but doesn't
plot(www,[xx;yy;zz]);
do the job for you? I do not have the optimization toolbox, so I can't test your script. But in principle, this should work.

MATLAB: errorn in butter() command

I wrote the following function:
function [output_signal] = AddDirectivityError (bat_loc_index, butter_deg_vector, sound_matrix)
global chirp_initial_freq ;
global chirp_end_freq;
global sampling_rate;
global num_of_mics;
global sound_signal_length;
for (i=1 : num_of_mics)
normalized_co_freq = (chirp_initial_freq + chirp_end_freq)/ (1.6* sampling_rate);
A=sound_matrix ( i, : ) ;
peak_signal=max(A);
B=find(abs(A)>peak_signal/100);
if (butter_deg_vector(i)==0)
butter_deg_vector(i)=2;
end
[num, den] = butter(butter_deg_vector(i), normalized_co_freq, 'low');// HERE!!!
filtered_signal=filter(num,den, A );
output_signal(i, :)=filtered_signal;
end
This functions runs many-many times without any error. However, when I reach the line: [num, den] = butter ( butter_deg_vector(i), normalized_co_freq, 'low');
And the local variables are: i=3, butter_deg_vector(i)=1, normalized_co_freq=5.625000e-001
MATLAB prompts an error says:
??? Error using ==> buttap Expected N to be integer-valued.
"Error in ==> buttap at 15 validateattributes(n,{'numeric'},{'scalar','integer','positive'},'buttap','N');
Error in ==> butter at 70 [z,p,k] = buttap(n);"
I don't understand why this problem occurs especially in this iteration. Why does this function prompt an error especially in this case?
Try to change the code line for:
[num, den] = butter (round(butter_deg_vector(i)), normalized_co_freq, 'low');

matlab - Error using ./ Matrix dimensions must agree

Why am i getting this error?
In this program I want to get a linear regression. Next, I want to remove outlier data. Then, outliers are colored red, and normal points colored blue, the fitting line is colored green.
In this program in end command occurs an error. Can someone help me understand why?
x=[-0.05623 -0.20968 0.192102 0.992332 0.576244 1.305784 ...
-0.72931 -0.86457 -0.09492 1.383214 1.303681 -0.12581 ...
-0.59687 -1.52065 0.671842 0.022844 -1.17779 -0.33458 ...
-1.82946 0.42999 -0.17399 1.631242 -1.35943 0.970507 ...
0.14364 0.082604 0.716664 1.193484 -1.07106 1.318902 ...
-1.21 -1.07411 -0.67256 0.736462 -1.06996 0.334715 ...
0.411883 0.15412 0.554571 -1.17285 1.007587 0.11352 ...
0.730051 -0.98351 0.052032 0.877599 1.014141 -0.08435 ...
-1.85353 -1.09682 0.218628 0.794246 0.463124 -0.61263 ...
2.2444 0.072348 0.865514 -0.4157 -1.11494 0.685252 ...
1.037673 1.822212 -0.52899 -1.62797 1.617302 0.264137 ...
-1.12715 -0.55918 -0.80885 1.161004 0.592105 0.242748 ...
0.240477 -0.8215 0.993112 0.346395 -0.26113 -0.18471 ...
-0.10173 -0.88704 0.741377 1.392208 2.4739 0.503919 ...
-0.82248 0.200982 -1.00705 -0.61317 -0.65896 -0.83323 ...
0.378179 -1.11534 0.667241 0.795333 1.037492 -0.02043 ...
0.618953 1.803064 0.052993 -0.17789];
y=[5.436978 3.947596 5.153861 7.203315 5.725703 6.793873 3.545316 3.936359 ...
4.237048 6.839705 7.122279 4.810857 4.288197 2.756219 6.208018 4.655615 ...
3.29746 4.037378 2.486194 5.55364 4.931752 7.288785 3.057518 6.765781 ...
4.633195 4.574674 5.536068 7.039812 3.51258 6.771749 3.625891 3.429356 ...
3.524448 5.804945 2.987637 5.782922 5.441024 4.886507 5.662118 2.994722 ...
6.762253 5.310672 6.183994 3.647019 5.090687 6.037325 6.680508 4.631969 ...
1.904436 3.03886 5.583692 6.479913 5.177385 4.037497 8.4407 4.928997 ...
6.522089 4.451288 3.282642 5.863934 6.755633 7.983111 4.344549 2.487526 ...
7.696832 5.129475 3.351763 4.571945 3.730939 6.493319 6.459757 5.291498 ...
5.490604 3.531393 6.574259 5.65695 4.609641 4.81884 5.201688 3.25646 ...
6.172526 6.502666 8.719206 6.323678 4.043084 5.299436 3.389938 4.235615 ...
4.322408 3.754491 6.042199 3.087029 5.413286 5.972943 6.497619 4.859718 ...
5.679203 8.097901 4.604103 4.588513];
n=1
p=polyfit(x,y,n);
a=p(1); b=p(2);
ymodel=a*x+b;
plot(x,y,'o',x,ymodel);
all_idx = 1:length(x);
outlier_idx = abs(x -median(x)) > 2*std(x) | abs(y - median(y)) > 2*std(y)
x(outlier_idx) = interp1(all_idx(~outlier_idx), ...
x(~outlier_idx), all_idx(outlier_idx));
y(outlier_idx) =interp1(all_idx(~outlier_idx), ...
y(~outlier_idx), all_idx(outlier_idx));
x_out_ind = find(outlier_idx); % gives the index of outliers
% the next line gives an error: matrix dimensions must agree:
x_normal_ind = find(ones(1,00)-x_out_ind); % gives the index of normal
for i=x_normal_ind
% this plot command gives an error:
plot(x(i),y(i),'o','blue')
hold on
end
for i=x_out_ind
% this plot command gives an error:
plot(x(i),y(i),'o','red')
hold on
end
plot(x,a*x+b,'green')
First error is because ones(1,00) will return an empty matrix which is not the same size as x_out_ind i.e. matrix dimensions do not agree.
Second error is because you have supplied two strings to the plot command. This is often treated as a 'property':'value' pairing. So it is saying that the property 'o' is not valid.
I'd suggest using 'dbstop if error' and track down the errors one at a time.

reducing running time for matlab for loops

my matlab code bellow takes a very long time to run. How could I compose it to take just seconds to run? I would be thankful if you could help me. parameters i, k_hat and alpha are constants.
%%%%%%%%%%%%%%%%%%%
p_desired=zeros(1,length(alpha));
p_ICI=zeros(1,length(alpha));
p_MUI=zeros(1,length(alpha));
tic
for ss=1:length(alpha)
uN=2*pi/N*Ts*abs(sin(alpha(ss)));
uM=2*pi/M*Ts*abs(sin(alpha(ss)));
for j=0:M/N-1
for k=0:N-1
for q=0:N-1
for qq=0:N-1
for q_hat=0:N-1
for qq_hat=0:N-1
for n=0:M-1
for m=-Ng:M-1
for n_hat=0:N-1
for m_hat=-Ng:N-1
if (n-m-n_hat+m_hat==0)
if (i==j && k==k_hat)
p_desired(ss)=p_desired(ss)+((sin(-alpha(ss))-1i*cos(-alpha(ss)))/N)^.5*exp(1i/2*k_hat^2*cot(-alpha(ss))*uN^2)*exp(1i/2*q^2*cot(-alpha(ss))*Ts^2)*exp(-1i*2*pi*q*k_hat/N)...
*((sin(-alpha(ss))+1i*cos(-alpha(ss)))/N)^.5*exp(-1i/2*k_hat^2*cot(-alpha(ss))*uN^2)*exp(-1i/2*q_hat^2*cot(-alpha(ss))*Ts^2)*exp(+1i*2*pi*q_hat*k_hat/N)...
* ((sin(alpha(ss))-1i*cos(alpha(ss)))/N)^.5*exp(1i/2*qq^2*cot(alpha(ss))*uN^2)*exp(1i/2*k_hat^2*cot(alpha(ss))*Ts^2)*exp(-1i*2*pi*qq*k_hat/N)...
*((sin(alpha(ss))+1i*cos(alpha(ss)))/N)^.5*exp(-1i/2*qq_hat^2*cot(alpha(ss))*uN^2)*exp(-1i/2*k_hat^2*cot(alpha(ss))*Ts^2)*exp(+1i*2*pi*qq_hat*k_hat/N)...
*((sin(alpha(ss))-1i*cos(alpha(ss)))/M)^.5*exp(1i/2*(q+N*(i-1))^2*cot(alpha(ss))*uM^2)*exp(1i/2*n^2*cot(alpha(ss))*Ts^2)*exp(-1i*2*pi*(q+N*(i-1))*n/M)...
*((sin(alpha(ss))+1i*cos(alpha(ss)))/M)^.5*exp(-1i/2*(q_hat+N*(i-1))^2*cot(alpha(ss))*uM^2)*exp(-1i/2*n_hat^2*cot(alpha(ss))*Ts^2)*exp(+1i*2*pi*(q_hat+N*(i-1))*n_hat/M)...
*((sin(-alpha(ss))-1i*cos(-alpha(ss)))/M)^.5*exp(1i/2*m^2*cot(-alpha(ss))*uM^2)*exp(1i/2*(qq+N*(i-1))^2*cot(-alpha(ss))*Ts^2)*exp(-1i*2*pi*m*(qq+N*(i-1))/M)...
*((sin(-alpha(ss))+1i*cos(-alpha(ss)))/M)^.5*exp(-1i/2*m_hat^2*cot(-alpha(ss))*uM^2)*exp(-1i/2*(qq_hat+N*(i-1))^2*cot(-alpha(ss))*Ts^2)*exp(+1i*2*pi*m_hat*(qq_hat+N*(i-1))/M)...
*exp(1i*2*pi/M*(n-n_hat)*e)*exp(-abs(n-m)/gamma)* besselj(0,2*pi*abs(n-n_hat)*fd);
elseif (i==j && k~=k_hat)
p_ICI(ss)=p_ICI(ss)+((sin(-alpha(ss))-1i*cos(-alpha(ss)))/N)^.5*exp(1i/2*k_hat^2*cot(-alpha(ss))*uN^2)*exp(1i/2*q^2*cot(-alpha(ss))*Ts^2)*exp(-1i*2*pi*q*k_hat/N)...
*((sin(-alpha(ss))+1i*cos(-alpha(ss)))/N)^.5*exp(-1i/2*k_hat^2*cot(-alpha(ss))*uN^2)*exp(-1i/2*q_hat^2*cot(-alpha(ss))*Ts^2)*exp(+1i*2*pi*q_hat*k_hat/N)...
* ((sin(alpha(ss))-1i*cos(alpha(ss)))/N)^.5*exp(1i/2*qq^2*cot(alpha(ss))*uN^2)*exp(1i/2*k^2*cot(alpha(ss))*Ts^2)*exp(-1i*2*pi*qq*k/N)...
*((sin(alpha(ss))+1i*cos(alpha(ss)))/N)^.5*exp(-1i/2*qq_hat^2*cot(alpha(ss))*uN^2)*exp(-1i/2*k^2*cot(alpha(ss))*Ts^2)*exp(+1i*2*pi*qq_hat*k/N)...
*((sin(alpha(ss))-1i*cos(alpha(ss)))/M)^.5*exp(1i/2*(q+N*(i-1))^2*cot(alpha(ss))*uM^2)*exp(1i/2*n^2*cot(alpha(ss))*Ts^2)*exp(-1i*2*pi*(q+N*(i-1))*n/M)...
*((sin(alpha(ss))+1i*cos(alpha(ss)))/M)^.5*exp(-1i/2*(q_hat+N*(i-1))^2*cot(alpha(ss))*uM^2)*exp(-1i/2*n_hat^2*cot(alpha(ss))*Ts^2)*exp(+1i*2*pi*(q_hat+N*(i-1))*n_hat/M)...
*((sin(-alpha(ss))-1i*cos(-alpha(ss)))/M)^.5*exp(1i/2*m^2*cot(-alpha(ss))*uM^2)*exp(1i/2*(qq+N*(i-1))^2*cot(-alpha(ss))*Ts^2)*exp(-1i*2*pi*m*(qq+N*(i-1))/M)...
*((sin(-alpha(ss))+1i*cos(-alpha(ss)))/M)^.5*exp(-1i/2*m_hat^2*cot(-alpha(ss))*uM^2)*exp(-1i/2*(qq_hat+N*(i-1))^2*cot(-alpha(ss))*Ts^2)*exp(+1i*2*pi*m_hat*(qq_hat+N*(i-1))/M)...
*exp(1i*2*pi/M*(n-n_hat)*e)*exp(-abs(n-m)/gamma) *besselj(0,2*pi*abs(n-n_hat)*fd);
elseif (i~=j)
p_MUI(ss)=p_MUI(ss)+((sin(-alpha(ss))-1i*cos(-alpha(ss)))/N)^.5*exp(1i/2*k_hat^2*cot(-alpha(ss))*uN^2)*exp(1i/2*q^2*cot(-alpha(ss))*Ts^2)*exp(-1i*2*pi*q*k_hat/N)...
*((sin(-alpha(ss))+1i*cos(-alpha(ss)))/N)^.5*exp(-1i/2*k_hat^2*cot(-alpha(ss))*uN^2)*exp(-1i/2*q_hat^2*cot(-alpha(ss))*Ts^2)*exp(+1i*2*pi*q_hat*k_hat/N)...
* ((sin(alpha(ss))-1i*cos(alpha(ss)))/N)^.5*exp(1i/2*qq^2*cot(alpha(ss))*uN^2)*exp(1i/2*k^2*cot(alpha(ss))*Ts^2)*exp(-1i*2*pi*qq*k/N)...
*((sin(alpha(ss))+1i*cos(alpha(ss)))/N)^.5*exp(-1i/2*qq_hat^2*cot(alpha(ss))*uN^2)*exp(-1i/2*k^2*cot(alpha(ss))*Ts^2)*exp(+1i*2*pi*qq_hat*k/N)...
*((sin(alpha(ss))-1i*cos(alpha(ss)))/M)^.5*exp(1i/2*(q+N*(i-1))^2*cot(alpha(ss))*uM^2)*exp(1i/2*n^2*cot(alpha(ss))*Ts^2)*exp(-1i*2*pi*(q+N*(i-1))*n/M)...
*((sin(alpha(ss))+1i*cos(alpha(ss)))/M)^.5*exp(-1i/2*(q_hat+N*(i-1))^2*cot(alpha(ss))*uM^2)*exp(-1i/2*n_hat^2*cot(alpha(ss))*Ts^2)*exp(+1i*2*pi*(q_hat+N*(i-1))*n_hat/M)...
*((sin(-alpha(ss))-1i*cos(-alpha(ss)))/M)^.5*exp(1i/2*m^2*cot(-alpha(ss))*uM^2)*exp(1i/2*(qq+N*(j-1))^2*cot(-alpha(ss))*Ts^2)*exp(-1i*2*pi*m*(qq+N*(j-1))/M)...
*((sin(-alpha(ss))+1i*cos(-alpha(ss)))/M)^.5*exp(-1i/2*m_hat^2*cot(-alpha(ss))*uM^2)*exp(-1i/2*(qq_hat+N*(j-1))^2*cot(-alpha(ss))*Ts^2)*exp(+1i*2*pi*m_hat*(qq_hat+N*(j-1))/M)...
*exp(1i*2*pi/M*(n-n_hat)*e)*exp(-abs(n-m)/gamma)* besselj(0,2*pi*abs(n-n_hat)*fd);
end
else
p_desired(ss)=p_desired(ss);
p_ICI(ss)=p_ICI(ss);
p_MUI(ss)=p_MUI(ss);
end
end
end
end
end
end
end
end
end
end
end
end
toc
Remove "for ss=1:length(alpha)" and corresponding "end"
Convert all "alpha(ss)" to "alpha"
Convert all "p_desired(ss)" to "p_desired"
Convert all "p_ICI(ss)" to "p_ICI"
Convert all "p_MUI(ss)" to "p_MUI"
Convert all "*", "/" and "^" to ".*", './' and ".^" respectively.
Convert "elseif (i~=j)" to "else"
Remove below code:
else
p_desired(ss)=p_desired(ss);
p_ICI(ss)=p_ICI(ss);
p_MUI(ss)=p_MUI(ss);

Compile error of the .f source code in gfortran; reading a text file into 2D array

I have a problem with the following source. When it is compiled in gfortran, it does not work properly and then two error message showed up.
How do I solve this problem?
Any comment would be very helpful.
Thanks in advance.
program driver
integer i,ln,n,e,count,x,a,b,total
character driverid*12,var*12,ch*12
parameter (n=720321)
c parameter (n=55062)
dimension var(n),a(n),b(n)
write(*,*) 'input run id(text)'
read(*,55) driverid
55 format(a)
ln=index(driverid,' ')-1
open(6,file=driverid(1:ln)//'.out',form='formatted'
+,status='unknown')
open(1,file=driverid(1:ln)//'.txt',status='old')
do i=1,2
read(1,*)
end do
read(1,*) (var(i),i=1,n)
close(1)
total=0
count=1
do i=1,n
b(i)=0
read(var(i),*,iostat=e) x
if (e .eq. 0) then
a(count)=x
count=count+1
else
ln=index(var(i),' ')-1
if (var(i)(ln-1:ln-1) .eq. 'r') then
var(i)=var(i)(1:ln-2)
else
var(i)=var(i)(1:ln-1)
end if
read(var(i),'(i)') b(count-1)
end if
end do
do i=1,count
total=total+1+b(i)
end do
do i=1,total
write(6,'(10i)') (a(i),j=1,b(i))
end do
close(6)
end
Error message is following as
$ gfortran driver.f
driver.f:43.23:
read(var(i),'(i)') b(count-1)
1
Error: Nonnegative width required in format string at (1)
driver.f:53.20:
write(6,'(10i)') (a(i),j=1,b(i))
1
Error: Nonnegative width required in format string at (1)
When specifying a format for an integer, you must specify the field width. If you want to have it flexible, you can set it to zero:
write(6, "(10I0)") ...