Some problems using map/container with if-else statement in nested for loops
Hi everyone, this is my following code with the use of map and container with if-else statement in nested for loops. I don’t understand why the error Unrecognized function or variable ‘Intensitysol1’ appears, while there is no problem for Intensitysol2. How should I fix it?
theta=0.65;
J=0.08;
for ii = 0:1:49;
omega_y(ii+1) = 0 + (0.15/100)*(ii);
end
for jj = 0:1:100;
omega_z(jj+1) = 0 -(0.15/100)*(jj);
end
valueset_omega_y_vector = 1:1:(length(omega_y));
valueset_omega_z_vector= 1:1:(length(omega_z));
M_omega_y = containers.Map(omega_y,valueset_omega_y_vector);
M_omega_z = containers.Map(omega_z, valueset_omega_z_vector);
for ii = 1:1:49
for jj = 0:1:100
u = 0 : 2*pi/1000 : 2*pi;
E_minus = 2*J*cos(theta).*cos(u) – (sqrt(omega_y(ii+1)^2 + omega_z(jj+1)^2 + 4*(J^2)*((sin(theta))^2).*((sin(u)).^2) -4*J*omega_z(jj+1)*sin(theta).*sin(u)));
TF = islocalmin(E_minus);
a=u(TF);
if size(a)==2
Intensitysol1(M_omega_y(omega_y(ii+1)),M_omega_z(omega_z(jj+1)))=a(1);
Intensitysol2(M_omega_y(omega_y(ii+1)),M_omega_z(omega_z(jj+1)))=a(2);
elseif size(a)==1
Intensitysol2(M_omega_y(omega_y(ii+1)),M_omega_z(omega_z(jj+1)))=a(1);
end
end
end
figure(1)
surf(omega_z, omega_y, Intensitysol1)
xlabel(‘omega_z’)
ylabel(‘omega_y’)
zlabel(‘k’)
figure(2)
surf(omega_z, omega_y, Intensitysol2)
xlabel(‘omega_z’)
ylabel(‘omega_y’)
zlabel(‘k’)Hi everyone, this is my following code with the use of map and container with if-else statement in nested for loops. I don’t understand why the error Unrecognized function or variable ‘Intensitysol1’ appears, while there is no problem for Intensitysol2. How should I fix it?
theta=0.65;
J=0.08;
for ii = 0:1:49;
omega_y(ii+1) = 0 + (0.15/100)*(ii);
end
for jj = 0:1:100;
omega_z(jj+1) = 0 -(0.15/100)*(jj);
end
valueset_omega_y_vector = 1:1:(length(omega_y));
valueset_omega_z_vector= 1:1:(length(omega_z));
M_omega_y = containers.Map(omega_y,valueset_omega_y_vector);
M_omega_z = containers.Map(omega_z, valueset_omega_z_vector);
for ii = 1:1:49
for jj = 0:1:100
u = 0 : 2*pi/1000 : 2*pi;
E_minus = 2*J*cos(theta).*cos(u) – (sqrt(omega_y(ii+1)^2 + omega_z(jj+1)^2 + 4*(J^2)*((sin(theta))^2).*((sin(u)).^2) -4*J*omega_z(jj+1)*sin(theta).*sin(u)));
TF = islocalmin(E_minus);
a=u(TF);
if size(a)==2
Intensitysol1(M_omega_y(omega_y(ii+1)),M_omega_z(omega_z(jj+1)))=a(1);
Intensitysol2(M_omega_y(omega_y(ii+1)),M_omega_z(omega_z(jj+1)))=a(2);
elseif size(a)==1
Intensitysol2(M_omega_y(omega_y(ii+1)),M_omega_z(omega_z(jj+1)))=a(1);
end
end
end
figure(1)
surf(omega_z, omega_y, Intensitysol1)
xlabel(‘omega_z’)
ylabel(‘omega_y’)
zlabel(‘k’)
figure(2)
surf(omega_z, omega_y, Intensitysol2)
xlabel(‘omega_z’)
ylabel(‘omega_y’)
zlabel(‘k’) Hi everyone, this is my following code with the use of map and container with if-else statement in nested for loops. I don’t understand why the error Unrecognized function or variable ‘Intensitysol1’ appears, while there is no problem for Intensitysol2. How should I fix it?
theta=0.65;
J=0.08;
for ii = 0:1:49;
omega_y(ii+1) = 0 + (0.15/100)*(ii);
end
for jj = 0:1:100;
omega_z(jj+1) = 0 -(0.15/100)*(jj);
end
valueset_omega_y_vector = 1:1:(length(omega_y));
valueset_omega_z_vector= 1:1:(length(omega_z));
M_omega_y = containers.Map(omega_y,valueset_omega_y_vector);
M_omega_z = containers.Map(omega_z, valueset_omega_z_vector);
for ii = 1:1:49
for jj = 0:1:100
u = 0 : 2*pi/1000 : 2*pi;
E_minus = 2*J*cos(theta).*cos(u) – (sqrt(omega_y(ii+1)^2 + omega_z(jj+1)^2 + 4*(J^2)*((sin(theta))^2).*((sin(u)).^2) -4*J*omega_z(jj+1)*sin(theta).*sin(u)));
TF = islocalmin(E_minus);
a=u(TF);
if size(a)==2
Intensitysol1(M_omega_y(omega_y(ii+1)),M_omega_z(omega_z(jj+1)))=a(1);
Intensitysol2(M_omega_y(omega_y(ii+1)),M_omega_z(omega_z(jj+1)))=a(2);
elseif size(a)==1
Intensitysol2(M_omega_y(omega_y(ii+1)),M_omega_z(omega_z(jj+1)))=a(1);
end
end
end
figure(1)
surf(omega_z, omega_y, Intensitysol1)
xlabel(‘omega_z’)
ylabel(‘omega_y’)
zlabel(‘k’)
figure(2)
surf(omega_z, omega_y, Intensitysol2)
xlabel(‘omega_z’)
ylabel(‘omega_y’)
zlabel(‘k’) containers, nestedloops, finding minimum, if-else statement MATLAB Answers — New Questions