Array indices must be positive integers or logical values.
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
tianxing huang
le 24 Jan 2023
Réponse apportée : Image Analyst
le 24 Jan 2023
i want implement the a gaussian Input in rectangle form and in circle form, sorry i dont know why first a worked, but seconed a not. The error is: ''Array indices must be positive integers or logical values''. Can someone help me
%% Parameter setup
L_x = 130e-6;
L_y = 330e-6;
dx_coarse = .5e-6; % Step coarse for fine step
dy_coarse = .5e-6; % Step coarse for fine step
x = -L_x/2 :dx_coarse : L_x/2;
y = -L_y/2 :dy_coarse : L_y/2;
y_coupcenter = 0;
x_coupcenter = 0;
n = ones(length(y),length(x))*n_glass;
n_dim = size(n);
length = 20; % um
width = 20; % um
GaussInput = 1*exp(-xg1.^2/(2*(sigma_x))^2 -yg1.^2/(2*(sigma_y))^2); % Definition of gaussian beam
% circle: a work
rad_coup = 25e-6;
Excitation.coup_center = [y((length(y)+1)/2 + y_coupcenter*1e6),x((length(x)+1)/2 + x_coupcenter*1e6)];
Excitation.gausscoup = sqrt((xg(:,:,1)-Excitation.coup_center(2)).^2+(yg(:,:,1)-Excitation.coup_center(1)).^2)<=rad_coup;
a = GaussInput(Excitation.gausscoup);
% rectangle: a not work
Excitation.gausscoup = zeros(length(y),length(x));
Excitation.gausscoup((n_dim(1)+1)/2 - y_coupcenter*1e6 - length/(2*dy_coarse*1e6): (n_dim(1)-1)/2 - y_coupcenter*1e6 + length/(2*dy_coarse*1e6), (n_dim(2)+1)/2 - x_coupcenter*1e6 - width/(2*dx_coarse*1e6) :(n_dim(2)-1)/2 - x_coupcenter*1e6 + width/(2*dx_coarse*1e6)) = 1;
a = GaussInput(Excitation.gausscoup); % Array indices must be positive integers or logical values.
0 commentaires
Réponse acceptée
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Startup and Shutdown dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!