# How can I call a function from a different script into a plot with other plot-values?

조회 수: 11 (최근 30일)
HZ-RAW . 2022년 1월 11일
댓글: Ive J . 2022년 1월 12일
I have the following values in my first script that can be plotted into a graph:
Script1:(The green text is in Swedish)
%%
close all
clear
clc
%P mot v
%Underkyld vätska: Tryck,P mot volymitet,v
y1=[10000000,1000000,100000,10000]; %Tryck,P
x1=[log(0.0009973),log(0.001002),log(0.001002),log(0.001002)]; %volymitet,v
y2=[10000000,1000000,100000,10000]; %Tryck,P
x2=[log(0.001452),log(0.06294),log(0.7434),log(7.457)]; %volymitet,v
y3=[10000000,1000000,100000,10000]; %Tryck,P
x3=[log(0.01803),log(0.1893),log(1.813),log(18.11)]; %volymitet,v
y4=[10000000,1000000,100000,10000]; %Tryck,P
x4=[log(0.03278),log(0.3312),log(3.316),log(33.16)]; %volymitet,v
figure(1)
plot(x1,y1,'-*',x2,y2,'-*',x3,y3,'-*',x4,y4,'-*',f(x))
ylabel('P')
xlabel('v')
hold on
grid on
But I also want to plot this following function into the same graph as in script1:
Script2:
% Funktion som tar fram p- och v-data för mättnadskurvorna för vatten
% Temperaturvektorn (mättnadsdata är funktioner av temperaturen) för kurvorna
% (kurvorna går från 0.01°C till 373.946°C)
Tm=[0.01 1:373 373.946];
% Tryckvektor för kurvorna (samma för båda)
Pkurva=pmatt_ASME(Tm);
[vfkurva,vgkurva]=vmatt_ASME(Tm);
end
This function plots a certain curve that helps me to analyze my data more accurately in my project. (P stands for pressure and v for volume) How do I do this? What input code do I need to type in Script1?

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

### 답변 (1개)

Ive J 2022년 1월 11일
편집: Ive J 님. 2022년 1월 11일
Something's wrong with your second function, seems there is no input argument(s). vmatt_ASME doesn't accept any argument rather Tm. Maybe Tm is supposed to be the input argument of PM_mattnadPv_H2O func? Because the second function uses Tm to calculate P and V (as far as I understood). In that case you can return P and V and plot them on the same axis as in script 1.
hold on
h = plot(x, y);
plot(h, Pkurva, vfkurva)
hold off
% Funktion som tar fram p- och v-data för mättnadskurvan för vatten
% Temperaturvektorn (mättnadsdata är funktioner av temperaturen) för kurvorna
% (kurvorna går från 0.01°C till 373.946°C)
% Tm=[0.01 1:373 373.946];
% Tryckvektor för kurvorna (samma för båda)
Pkurva=pmatt_ASME(Tm);
[vfkurva,vgkurva]=vmatt_ASME(Tm);
end
##### 댓글 수: 2이전 댓글 1개 표시이전 댓글 1개 숨기기
Ive J 2022년 1월 12일
Your function doesn't make any sense:
% where x and y are being used?
Tm=[0.01 1:373 373.946];
Pkurva=pmatt_ASME(Tm);
[vfkurva,vgkurva]=vmatt_ASME(Tm);
end

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

### 카테고리

Help CenterFile Exchange에서 Thermodynamics and Heat Transfer에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!

Translated by