# How I can run two different functions at the same time ?

조회 수: 48(최근 30일)
Akash Pal 2021년 8월 19일
답변: KSSV 2021년 8월 19일
function [ add, sub] = inp(x,y)
sub=x-y;
end
function [ mul,div ] =iput(x,y)
mul=x*y;
div=x/y;
end
These two functions are in differnt script .I am running them differntly .But I want to do it in a single time because in both case my inputs are same .So how I can do it ?

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

### 채택된 답변

Star Strider 2021년 8월 19일
I am not certain what you want, however one approach is to write a third function that returns all the outputs of the other functions:
x = randi(9)
x = 5
y = randi(9)
y = 4
[A,B,C,D] = CallFcns(x,y)
A = 9
B = 1
C = 20
D = 1.2500
function [A,B,C,D] = CallFcns(x,y)
[A,B] = inp(x,y);
[C,D] = iput(x,y);
end
function [ add, sub] = inp(x,y)
sub=x-y;
end
function [ mul,div ] =iput(x,y)
mul=x*y;
div=x/y;
end
.

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

### 추가 답변(1개)

KSSV 2021년 8월 19일

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

### 범주

Find more on Logical 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