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

37 views (last 30 days)
HZ-RAW on 11 Jan 2022
Commented: Ive J on 12 Jan 2022
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?

Ive J on 11 Jan 2022
Edited: Ive J on 11 Jan 2022
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 CommentsShowHide 1 older comment
Ive J on 12 Jan 2022
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

### Categories

Find more on Thermodynamics and Heat Transfer 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!

Translated by