How do I write the LHS code?

1 次查看(过去 30 天)
민제 강
민제 강 2021-6-11
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 个评论
Ashutosh Singh Baghel
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.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by