I know there are commands to use when finding the max values within an array, how would I do it through data from a graph?

1 次查看(过去 30 天)
%%% Data Give Within Question
a = 7;
b = 3;
x = [0,b];
N = 100;
y = 0;
%%% d2f(x) = -(20+(a*f(x)))*x*(x-b);
% Choosing appropriate value for discretization step h
h = 0.01;
for n=0:N
X(n+1) = h*n;
end
% Boundary Conditions
ua = 0;
ub = 0;
% Zero the A, u and B arrays
A = zeros(N+1,N+1);
B = zeros(N+1,1);
A(1,1)=1;
A(N+1,N+1)=1;
B(1)= ua;
B(N+1)= ub;
for n=2:N
A(n,n)=-2/h^2-a*X(n)^2+a*X(n)*b; % main diagonal
A(n,n+1)=1/h^2+X(n)/(2*h); % top diagonal
A(n,n-1)=1/h^2-X(n)/(2*h); % bottom diagonal
B(n)=20*X(n)*b - 20*X(n)^2;
end
U = linsolve(A,B);
plot(X,U,'--o')

回答(2 个)

Torsten
Torsten 2023-4-28
移动:Torsten 2023-4-28
I know there are commands to use when finding the max values within an array, how would I do it through data from a graph?
By using the array you plot the graph with.

Pratham Shah
Pratham Shah 2023-4-28
Why don't you use Min/Max function on the variable you are plotting. That will give you min/max value along with the corresponding index.

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by