Unable to store function output in an other variable

조회 수: 1 (최근 30일)
Muhammad Burhan Maqbool
Muhammad Burhan Maqbool 2015년 3월 2일
댓글: Muhammad Burhan Maqbool 2015년 3월 2일
I created a function to convert a degree value to radian. The function works fine and executed on command prompt. However, when I try to store the output of that function in to a variable, I get ' Too many output arguments error ' .
Below I am pasting the code of function:
function d2r(x) (x.*pi)./180
Above works fine
but doing below gives error
>> clear all >> a = d2r(45) Error using d2r Too many output arguments.

채택된 답변

Julia
Julia 2015년 3월 2일
Hi,
if you want to have an output you have to change your script:
function out = d2r(x)
out = (x.*pi)./180
Now you should be able to call
a = d2r(45)
without error

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by