Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 100-by-100.this is the error occuring.
i want to store a 100 x 100 matrix in hi_i for each iteration of irs1 and irs 2 when my sij1*sij2' is of 100x100 multiplied by a scalar in h_i.
    3 views (last 30 days)
  
       Show older comments
    
L=12;  % IRS
element=10;
lambda=0.06;
l=lambda/2;
%% channel between IRS and IRS
rr=11;
for irs1 = 1:(L-1)        % IRS1
    thetaa=2*pi*rand(rr) ; 
    thetae=2*pi*rand(rr) ;
    phi_a=2*pi*rand(rr) ; 
    phi_e=2*pi*rand(rr) ;
    ij=1;
    for irs2 = (irs1+1):L    % IRS2 
        %% AoA arrival 
        sij2=array_resp(10,phi_a(ij),phi_e(ij));   %100x1
        sij1=array_resp(10,thetaa(ij),thetae(ij)); %100x1
        hi_i(irs1,irs2)=(sqrt(alpha)/di_i(irs1,irs2))*(exp(-1j*(2*pi*di_i(irs1,irs2)/lambda)))*sij2*sij1'; %% distance between the IRSs
        hi_i(irs2,irs1)=hi_i(irs1,irs2);
        ij=ij+1;
    end
    rr=rr-1;
end
3 Comments
  Arif Hoq
      
 on 18 Feb 2022
				you can use 'cell array' to store your iteration value. what is the function:array_resp. if you have the code of this function please paste here
Answers (1)
  KSSV
      
      
 on 18 Feb 2022
        WE cannot correct your code as some variables are not defined. But still, your error is simple. You are trying to store a 100x100 matrix at a single element which you cannot. 
% Demo
A = zeros(3) ;   % 3x3 matrix intilaized 
A(1,1)   = rand ;   % a single element saved no error 
A(1,:) = rand(1,3) ;  % three elements stored at three places no error
A(3,3) = rand(3) ;  % error, you cannot store 3x3 matrix at a single element 
S the work around is, initiate the initial matrix properly and use correct indexing. 
If no store the matrices into a cell .
A = cell(2,2) ;
A{1,1} = rand(3) ; 
A{1,2} = rand(4) ; 
3 Comments
See Also
Categories
				Find more on Data Type Conversion in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

