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?
Afficher commentaires plus anciens
%%% 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')
Réponses (2)
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
le 28 Avr 2023
0 votes
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.
Catégories
En savoir plus sur Discrete Data Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
