error in 3d plotting.
Show older comments
% Define the equations for r(x) and theta(x) soln
%fun = @(x, y, mu, lambda, ke, ko) [y(2); (-x * y(2) + y(1) - ke^2 * x^2 / (2 * mu + lambda) * y(1) + ko^2 * x^2 * y(3) / (2 * mu + lambda)) / x^2; ...
% y(4); (-x * y(4) + y(3) - ko^2 / mu * x^2 * y(1) - ke^2 / mu * x^2 * y(3)) / x^2];
% Define the equations as x*r(x) and x*theta(x) soln
fun = @(x, y, mu, lambda, ke, ko) [x * y(2);
(-x^2 * y(2) + x * y(1) - (ke^2 * x^4) / (2 * mu + lambda) * y(1) + (ko^2 * x^4 * y(3)) / (2 * mu + lambda)) / x^2;
x * y(4);
(-x^2 * y(4) + x * y(3) - (ko^2 * x^4) / mu * y(1) - (ke^2 * x^4) / mu * y(3)) / x^2];
% Define the initial conditions
initialConditions = [0.2; 0; 0; 0]; % r(0.75) = 0.1625, r'(0.75) = 0, Theta(0.75) = 0, Theta'(0.75) = 0
% Define the parameter ranges
mu_r_range = linspace(3, 20, 12);
lambda_r_range = linspace(50, 100, 10);
mu_theta_range = linspace(3, 20, 12);
lambda_theta_range = linspace(50, 100, 10);
ke_range = linspace(0.0001, 0.6, 10);
ko_range = linspace(0.0001, 0.6, 10);
% Initialize arrays to store peak extremum values
peak_r = zeros(length(ke_range), length(ko_range));
peak_theta = zeros(length(ke_range), length(ko_range));
% Solve the differential equations for each combination of parameters
for m = 1:length(ke_range)
for n = 1:length(ko_range)
ke = ke_range(m);
ko = ko_range(n);
% Initialize arrays to store extremum values for each solution
extremum_r = zeros(size(mu_r_range));
extremum_theta = zeros(size(mu_theta_range));
for i = 1:length(mu_r_range)
for j = 1:length(lambda_r_range)
for k = 1:length(mu_theta_range)
for l = 1:length(lambda_theta_range)
mu_r = mu_r_range(i);
lambda_r = lambda_r_range(j);
mu_theta = mu_theta_range(k);
lambda_theta = lambda_theta_range(l);
% Solve the differential equations
[x, y] = ode45(@(x, y) fun(x, y, mu_r, lambda_r, ke, ko), [0.75, 210], initialConditions);
% Calculate extremum values for r(x) and Theta(x)
extremum_r(i) = max(abs([max(y(:, 1)), min(y(:, 1))])); % Absolute maximum between max and min
extremum_theta(k) = max(abs([max(y(:, 3)), min(y(:, 3))])); % Absolute maximum between max and min
end
end
end
end
% Store the peak extremum values for each combination of ke and ko
peak_r(m, n) = max(extremum_r);
peak_theta(m, n) = max(extremum_theta);
end
end
% Plot the peak extremum values of r(x) for each combination of ke and ko
figure;
surf(ke_range, ko_range, peak_r);
xlabel('ke');
ylabel('ko');
zlabel('Peak Extremum Value of r(x)');
title('Peak Extremum Values of r(x)');
% Plot the peak extremum values of Theta(x) for each combination of ke and ko
figure;
surf(ke_range, ko_range, peak_theta);
xlabel('ke');
ylabel('ko');
zlabel('Peak Extremum Value of Theta(x)');
title('Peak Extremum Values of Theta(x)');
Want to 3d plot of x*r(x) and x*theta(x) with respect to ke and ko. But not getting any peak in the 3d plots as it was mentioned in the code. Any suggestions with possible errors?
Accepted Answer
More Answers (0)
Categories
Find more on Pie Charts 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!