How do I write the LHS code?

4 views (last 30 days)
민제 강
민제 강 on 11 Jun 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 Comment
Ashutosh Singh Baghel
Ashutosh Singh Baghel on 31 Aug 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.

Sign in to comment.

Answers (0)

Categories

Find more on Chemistry in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!