I have a problem with semilogx command

Hello,
I want to have the x axis as a log scale however it doesn't want to work. This function basically plots cubic splines in order to generate a p-v diagram, however when i run the code it only gets the splines that are shaded onwards, so the first half of the graph is missing.
Any help?
Thank you
function pv_plot(V,c1,c2,c3, c4, V_input_1, V_input_2)
for i = 2:72
x = V(i-1):((V(i+1)- V(i))/100):V(i);
y = (c1(i).*((V(i+1)-x).^3))+(c2(i).*((x-V(i)).^3))+(c3(i).*(V(i+1)-x))+(c4(i).*(x-V(i)));
semilogx(x,y)
if V(i-1)>V_input_1 && V(i)<V_input_2
H = area (x,y, 'EdgeColor', 'r');
hold on;
set(H(1), 'FaceColor', 'r');
end
end
hold off
end

댓글 수: 4

Walter Roberson
Walter Roberson 2019년 12월 9일
Your plot has broken lines that hint you have infinity or nan values in your inputs.
dpb
dpb 2019년 12월 9일
Let's see enough to reproduce the actual data. What was the input to the function or attach x,y as .mat file.
semilogx won't handle negative values if something goes wrong for x...that we can't see.
Walter's comment is apropos, too, fer shure...
Nadine Nassar
Nadine Nassar 2019년 12월 10일
X is an array of 73 values of volume. (0.00316 to 219.9)
Y is a cubic spline i created
The function basically requires two values of volume then outputs the corresponding pressure (through cubic spline interpolation) and the boundary work (area between v1 and v2) and the bulk modulus (differentiation).
The graph should plot the whole pv curve but im not sure why it doesnt show the whole graph
Walter Roberson
Walter Roberson 2019년 12월 10일
Copies of V,c1,c2,c3, c4, V_input_1, V_input_2 would allow us to test the code to track down the problem.

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Splines에 대해 자세히 알아보기

질문:

2019년 12월 9일

댓글:

2019년 12월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by