matlab有没有一种类似c语言return的函数,就是返回值后退出

来源:百度知道 编辑:UC知道 时间:2024/05/11 03:24:28
就是在程序中间直接退出

你是什么意思
c里面的return函数返回函数值
你的目的是要编写自定义函数吗?
matlab里面可以建立函数文件实现自定义函数

%%%%%%%%%%%%%%%保存为fun_name.m%%%%%%%%%%%%%%%
function [a,,b,c,d]=fun_name(x,y,z)
%然后写传出参量与传入参量的关系
%传入或者传出参量可以是一个或者多个
%例如...
a=x;
b=x*y;
c=y>x;
d=x+y*z;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
在主程序里面调用自定义函数即可
例如
clear
[a1,a2,a3,a4]=fun_name(1,2,3)
那么执行后
a1=1
a2=2
a3=1
a4=7

返回值后退出?不是运行完就自动退出了么?
能说的详细点么?不大懂你的意思。

和C语言一样,可以使用break

matlab本身也有return函数。

>> help return
RETURN Return to invoking function.
RETURN causes a return to the invoking function or to the keyboard.
It also terminates the KEYBOARD mode.

Normally functions return when the end of the function is reached.
A RETURN statement can be used to force an early return.

Example
function d = det(A)
if isempty(A)