MATLAB Answers

Function with two outputs only giving one output

2 views (last 30 days)
Brian Wells
Brian Wells on 29 Sep 2020
Commented: Walter Roberson on 30 Sep 2020
function [C K] = FTOCK (degreeF)
%FTOCK converts degrees reading in farenheit to celcius and then kelvin
%fprintf('%.1f degrees in Farenheit Translates to %.2f degrees Celcius and %.2f degrees Kelvin\n',degreeF,C,K);
I do not know why this only outputs the calculated Celsius degree, K is clearly within the brackets.
  1 Comment
Brian Wells
Brian Wells on 29 Sep 2020
I want two outputs. Coded like this it only outputs the Celsius

Sign in to comment.

Answers (1)

Xingwang Yong
Xingwang Yong on 29 Sep 2020
Apparently, the code is right.
I assume you are new to matlab.
You should use
[C K] = FTOCK (degreeF)
to receive two outputs instead of
c = FTOCK (degreeF)
Walter Roberson
Walter Roberson on 30 Sep 2020
When you used
[C K] = FTOCK (degreeF)
then was there an error message, such as there not being enough outputs?
If not, then what happened when you

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!