How to deal the points on matrix with specific width size using Matlab?
    7 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
Hi Matlab community members,
i am using this code to  fill or label as '1' in the matrix with respect to width size as 10 
So if the ii and jj indexes are present, the number 1 will be filled. its good. 
But  i need help how to deal that matrix where only zeros are present.
i want to fill that grid only as '0'. I tried to use if else statement but could not succed.
Will be very thankful for guidance and help. 
regards, 
xx =  -40:10:40;
yy =  -40:10:40;
Boundary_x = 10*floor(Slice_x/10);
Boundary_y = 10*floor(Slice_y/10);
[~,ii]=ismember(Boundary_x,xx);
[~,jj] = ismember(Boundary_y,yy);
Result_matrix(sub2ind([Size_x,Size_y],ii,jj))=1;
2 comentarios
  KSSV
      
      
 el 8 de Jun. de 2020
				VEry confusing. Question is not clear. Can you show with one working example? 
Respuestas (1)
  KSSV
      
      
 el 8 de Jun. de 2020
        If you know the dimensions of the Result_matrix you can initialize it either zeros or NaNs or ones. Depending on your requirement. 
m = 10 ;   % number of rows 
n = 10 ;   % number of columns
P = zeros(m,n) ;  % all m*n zeros
Q = NaN(m,n) ;    % all m*n NaNs
R = ones(m,n) ;   % all m*n ones 
Ver también
Categorías
				Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

