Effacer les filtres
Effacer les filtres

How do I write the LHS code?

2 vues (au cours des 30 derniers jours)
민제 강
민제 강 le 11 Juin 2021
I want to get points through the LHS within the Rosenbrock function.
f(x)=100*(x2-x1^2)^2 + (1-x1)^2
x1^2 + x2^2 <= 1
Please let me know. Thank you!
  1 commentaire
Ashutosh Singh Baghel
Ashutosh Singh Baghel le 31 Août 2021
Hi,
I beleive you wish to plot the 'Rosenbrock function '. Please refer to a simple example provided below.
x_int = [0 1];
y_int = [0 1];
[X Y] = meshgrid(linspace(x_int(1),x_int(2),150),linspace(y_int(1),y_int(2),150));
mask = X.^2 + Y.^2 <=1; %extracting points on grid where condition fails
X(~mask) = nan; %putting values of invalid x and y as nan
Y(~mask) = nan;
myFun = @(X,Y) (100*(Y-X.^2).^2 + (1 - X).^2); %creating function handle for equation of Rosenbrock function
mesh(X,Y,myFun(X,Y)); %plotting on mesh grid
var_values = myFun(X,Y); %extract the points within rosenbroke function
Please refer to the matlab documentation page for function handles.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Chemistry 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!

Translated by