how to show a function ?

2 views (last 30 days)
César Arturo Niño Carmona
% FIRST SCRIPT. I NEED TO SHOW THE SAME GRAPHICS IN THE SAME IN BOTH SCRIPTS !!. PLEASE
clc
clear
CC = input ('Ingrese la COMPLIANCIA (cm3/cmH2O)DEL PULMON C = ');
C= CC/981;
subplot (2,2,1)
syms t
Q1 = 1
hold on
fplot(Q1,[0 1])
Q2 = t
fplot(Q2,[1 2])
Q3 = 2
fplot(Q3,[2 3])
axis([0 3 0 3])
title ("FLUJO Q, VARIANTE AL TIEMPO")
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Ro=1; G=981; A1=100; A2=150; A3=125;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
syms x
V1 =(Q1*t)
subplot (2,2,3)
hold on
fplot(V1,[0 1])
V2 =(Q2*t)
fplot(V2,[1 2])
V3 =(Q3*t)
fplot(V3,[2 3])
axis([0 3 0 6])
title ("VOLUMEN, VARIANTE AL TIEMPO")
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RO=1; G=981;
P1=V1/(C*RO*G)
subplot (2,2,4)
hold on
fplot(P1,[0 1])
P2=V2/(C*RO*G)
hold on
fplot(P2,[1 2])
P3=V3/(C*RO*G)
hold on
fplot(P3,[2 3])
axis([0 3 0 0.5])
title ("PRESION, VARIANTE AL TIEMPO")
%SECOND SCRPT
clc;clear
CC = input ('Ingrese la COMPLIANCIA (cm3/cmH2O)DEL PULMON C = ');
C= CC/981;
subplot (2,2,1)
t=0:0.01:3;
hold on
plot(t,flujo);grid on % AQUÍ LLAMO A LA FUNCION FLUJO
title ("FLUJO Q, VARIANTE")
axis([0 3 0 3])
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Ro=1; G=981; A1=100; A2=150; A3=125;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
syms t
V1 =(flujo*t)
subplot (2,2,3)
hold on
fplot(V1,[0 3])
axis([0 3 0 6])
title ("VOLUMEN, VARIANTE AL TIEMPO")
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RO=1; G=981;
P1=V1/(C*Ro*G)
subplot (2,2,4)
hold on
fplot(P1,[0 3])
axis([0 3 0 0.5])
title ("PRESION, VARIANTE AL TIEMPO")
% SCRIPT ABOUT THE FUNCTION
function [Q] = flujo (t)
t=0:0.01:3;
%Q = ((t>0)&(t<1)).*(3-2*t)+ ((t>=1)&(t<2)).*(3*t-6)+ ((t>=2)&(t<=3)).*(0);
Q = ((t>0)&(t<1)).*(1)+ ((t>=1)&(t<2)).*(t)+ ((t>=2)&(t<=3)).*(2);
% Q = ((t>0)&(t<1)).*(2*t)+ ((t>=1)&(t<2)).*(3)+ ((t>=2)&(t<=3)).*(3-t);
plot(t,Q)
grid on
axis([0 3 -4 4])
end

Answers (0)

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!