Matlab Functions and GUI

1 次查看(过去 30 天)
Neshant Thiru
Neshant Thiru 2020-5-5
编辑: Rik 2020-5-5
I keep getting an error saying that I'm "Out of memory. The likely cause is an infinite recursion within the program.".
I'm trying to incorporate a function with a Matlab GUI.
function [num] = fahrenheit(x, totype)
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
if fahrenheit(x,'Celsius to Fahrenheit')
num =(x * 9/5) + 32;
end
end
And this is the Callback function within the GUI.
function ConvertButtonPushed(app, event)
value = app.DirectionDropDown.Value;
conversion = app.ValueEditField.Value;
[f] = fahrenheit(conversion,value);
app.ConversionOutputLabel.Text = ['Conversion Output = ' num2str(f)];
end

回答(1 个)

Rik
Rik 2020-5-5
编辑:Rik 2020-5-5
You have a recursive function that doesn't get anywhere: if fahrenheit(x,___). At that point the function calls itself. Before trying to incorporate a function in a GUI, you need to make sure it works in the first place.
You probably mean to compare the second input to a specific text. You should use the strcmp function to do that.

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by