how can i plot this function?

조회 수: 2 (최근 30일)
FRANCESCA CANALE
FRANCESCA CANALE 2022년 6월 19일
댓글: Walter Roberson 2022년 6월 21일
I have to plot this formula:
on matlab:
%Meyer-Peter Muller
taus=0.01:1;
tausc1=0.047;
fi1=8*(taus-tausc1).^(3/2);
and I have write like this:
subplot (2,2,1) %Meyer-Peter Muller
hold on
plot(taus,fi1,'LineWidth',3)
grid on
axis([0.01 1 0.001 10])
set(gca,'XScale','log');
set(gca,'YScale','log');
xlabel('\tau_*')
ylabel('\phi_o')
but there is this error:
Warning: Imaginary parts of complex X and/or Y arguments ignored.

채택된 답변

Sam Chak
Sam Chak 2022년 6월 20일
Because that is not an ordinary plot, but a plot using base-10 logarithmic scale on the x-axis and the y-axis. I have made changes in 3 lines. See comments.
% Meyer-Peter Muller
taus = linspace(0.048, 10, 4977); % ← Changes in this line
tausc1=0.047;
fi1=8*(taus-tausc1).^(3/2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Figures
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% subplot (2,2,1) % Meyer-Peter Muller
% hold off
loglog(taus,fi1,'LineWidth',3) % ← Changes in this line
grid on
axis([1e-2 1e0 1e-4 1e1]) % ← Changes in this line
set(gca,'XScale','log');
set(gca,'YScale','log');
xlabel('\tau_*')
ylabel('\phi_o')

추가 답변 (1개)

Walter Roberson
Walter Roberson 2022년 6월 19일
0.01 minus 0.047 is negative. negative raised to 3/2 is complex. Your x are non-negative real but your fi1 are a mix of real and complex values.
You also ask for log scale for both axes. log of a complex value would be complex, so it is not obvious what you want plotted.
0.01:1 is the single value 0.01. Remember that the default increment is 1
What do you expect a log plot of complex values to look like?
  댓글 수: 2
FRANCESCA CANALE
FRANCESCA CANALE 2022년 6월 20일
thanks! So i write this:
%Meyer-Peter Muller
taus=0.05:10;
tausc1=0.047;
fi1=8*(taus-tausc1).^(3/2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Figures
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
subplot (2,2,1) %Meyer-Peter Muller
hold off
plot(taus,fi1,'LineWidth',3)
grid on
axis([0.05 10 0.00001 10])
set(gca,'XScale','log');
set(gca,'YScale','log');
xlabel('\tau_*')
ylabel('\phi_o')
but the plot on Matlab is very different by the real results and i don't know why:
Walter Roberson
Walter Roberson 2022년 6월 21일
I plotted the formula as given. I also used the general form of the formula, and read off some readings from the graph, and solve simultaneous equations to get approximate solutions.
Notice that the mulitiplier found through reading from the graph is fairly close to the 4 you already have, and that the exponent found through approximation is fairly close to the 3/2 you already have. The value supportraced has a notable difference though.
I had to choose representative values from the graph; it is possible that I did not pick consistent values.
syms a b c x
f(x,a,b,c) = a * (x-b)^c
f(x, a, b, c) = 
eqn1 = f(10^-1.75, a, b, c) == 10^-4
eqn1 = 
eqn2 = f(10^0, a, b, c) == 10^0.6
eqn2 = 
eqn3 = f(10^-1, a, b, c) == 10^-1
eqn3 = 
sol = solve([eqn1, eqn2, eqn3], a, b, c)
Warning: Unable to solve symbolically. Returning a numeric solution using vpasolve.
sol = struct with fields:
a: 4.0839873445232330597052367247964 b: 0.016976209741709958313669490402208 c: 1.4906441506377382534818813178019
f0 = f(x, 4, 0.047, 3/2)
f0 = 
f1 = subs(f(x,a,b,c), sol)
f1 = 
vpa(f1, 10)
ans = 
fplot([f0, f1], [0.05, 1])
set(gca, 'XScale', 'log', 'YScale', 'log')
legend({'Meyer-Peter Muller', 'Approximated from graph'})
xlim([10^-2, 10^0])
ylim([10^-4, 10^1])

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by