optimization of n for dual blaze wavelength

1 次查看(过去 30 天)
This code has two optimization value along with two weight i.e. [1541;3160;0.5;0.5]
everytime i run the code i recieved the mentioned error
Please provide the solution of same.
thank you
clear all
clc
% N=[linspace(700,5000,0.5) linspace(0,0.5,0.01)];
N= linspace(700,5000,500);
% n= linspace(0,0.5,500);
y = cell2mat(arrayfun(@roo2d, N, 'uniform', 0));
% Z = cell2mat(arrayfun(@roo2d, X, 'uniform', 0));
plot(N, y.');
yline(0, 'k')
format long g
[sol, fval1] = fsolve(@roo2d, 1300);
function F = roo2d(n)
F=[((sin(pi*((n(1)/700)-1))/(pi*((n(1)/700)-1)))^2)*n(3)+ ((sin(pi*((n(2)/700)-1))/(pi*((n(2)/700)-1)))^2)*n(4)-0.31;
((sin(pi*((n(1)/1100)-1))/(pi*((n(1)/1100)-1)))^2)*n(3)+ ((sin(pi*((n(2)/1100)-1))/(pi*((n(2)/1100)-1)))^2)*n(4)-0.42;
((sin(pi*((n(1)/1500)-1))/(pi*((n(1)/1500)-1)))^2)*n(3)+ ((sin(pi*((n(2)/1500)-1))/(pi*((n(2)/1500)-1)))^2)*n(4)-0.50;
((sin(pi*((n(1)/2000)-1))/(pi*((n(1)/2000)-1)))^2)*n(3)+ ((sin(pi*((n(2)/2000)-1))/(pi*((n(2)/2000)-1)))^2)*n(4)-0.59;
((sin(pi*((n(1)/2500)-1))/(pi*((n(1)/2500)-1)))^2)*n(3)+ ((sin(pi*((n(2)/2500)-1))/(pi*((n(2)/2500)-1)))^2)*n(4)-0.64;
((sin(pi*((n(1)/3000)-1))/(pi*((n(1)/3000)-1)))^2)*n(3)+ ((sin(pi*((n(2)/3000)-1))/(pi*((n(2)/3000)-1)))^2)*n(4)-0.655;
((sin(pi*((n(1)/3500)-1))/(pi*((n(1)/3500)-1)))^2)*n(3)+ ((sin(pi*((n(2)/3500)-1))/(pi*((n(2)/3500)-1)))^2)*n(4)-0.64;
((sin(pi*((n(1)/4000)-1))/(pi*((n(1)/4000)-1)))^2)*n(3)+ ((sin(pi*((n(2)/4000)-1))/(pi*((n(2)/4000)-1)))^2)*n(4)-0.59;
((sin(pi*((n(1)/4500)-1))/(pi*((n(1)/4500)-1)))^2)*n(3)+ ((sin(pi*((n(2)/4500)-1))/(pi*((n(2)/4500)-1)))^2)*n(4)-0.50;
((sin(pi*((n(1)/5000)-1))/(pi*((n(1)/5000)-1)))^2)*n(3)+ ((sin(pi*((n(2)/5000)-1))/(pi*((n(2)/5000)-1)))^2)*n(4)-0.39;
abs(n(3));
abs(n(4));
n(3)+n(4)-1];
end
I am receiving this error everytime
Index exceeds the number of array elements (1).
Error in multiroo2d>roo2d (line 13)
F=[((sin(pi*((n(1)/700)-1))/(pi*((n(1)/700)-1)))^2)*n(3)+
((sin(pi*((n(2)/700)-1))/(pi*((n(2)/700)-1)))^2)*n(4)-0.31;
Error in multiroo2d (line 6)
y = cell2mat(arrayfun(@roo2d, N, 'uniform', 0));

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by