Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

MATLAB: Write a GUI function that will display sliders for the temperature and w

ID: 3835837 • Letter: M

Question

MATLAB: Write a GUI function that will display sliders for the temperature and wind speed. The GUI will calculate the WFC for the given values, and display the results in a text box. It is recommended you choose minimum and maximum values for the sliders.

1. GUI #1: The wind chill factor (WCF) measures how cold it feels with a given temperature T (in OF) and wind speed (V, in mph). The formula is approximately 35.7 0.6T -35.7 V 0.43 (vo 16 (1) WCF Write a GUI function that will display sliders for the temperature and wind speed. The GUI will calculate the WFC for the given values, and display the result in a text box. It is recommended that you choose minimum and maximum values for the two sliders

Explanation / Answer

function SliderDisplay

    bgcolor = [0 .8 1];

    f = figure('Visible', 'off','Color',bgcolor,'Position',... [360, 500, 280,320]);

    set(f,'Name','Wind Chill')

    movegui(f,'center')

    minw = 5;

    maxw = 100;

    winit = 10;

    hwindslider = uicontrol('Style', 'slider',...'Position',[80,230,100, 50],'SliderStep',[.1 .1],... 'Callback',@callbackfn);

    hwmin = uicontrol('Style','text','BackgroundColor',... bgcolor,'Position', [40,235,30,30],... 'String', num2str(minw));

    hwmax = uicontrol('Style', 'text','BackgroundColor',... bgcolor,'Position', [190,235,30,30],... 'String', num2str(maxw));

    hwcurr = uicontrol('Style','text','BackgroundColor',... bgcolor,'Position',[100,180,60,40],'Strings,winit); hwlab = uicontrol 'Style" text" BackgroundColor',… bgcolor,'Position', [80,290,100,20],... 'String',…’Wind Speed slider’);

    mint = -50;

    maxt = 80;

    tinit = 40;

    htempslider = uicontrol('Style','slider',... 'Position',[80,110,100, 50],'SliderStep',[.1 .1],... 'Callback',Ocallbackfn);

    htmin = uicontrol('Style','text','BackgroundColor',... bgcolor,'Position', [40,115,30,30),... 'String', num2str(mint));

    htmax = uicontrol('Style', 'text','BackgroundColor',... bgcolor,'Position', [190,115,30,30],... 'String', num2str(maxt));

    htcurr = uicontrol('Style,'text','Backgroundcolor',... bgcolor,'Position',[100,60,60,40],'String', tinit); htlab = uicontrol('Style1,'text',1BackgroundColor',... bgcolor,'Position',[75,170,110,20],'String',... 'Temperature Slider');

    wcf = 35.7+.6*tinit-35.7*winitA.16+.43*tinit*winitA.16;

    hwcf = uicontrol('Style','text','BackgroundColor',... bgcolor,'Position',[70,30,120,20],... 'String',['WCF = ',num2str(wcf)],'Fontsize',10);

    set(f,'Visible','on');

   

    function callbackfn(source,eventdata)

        W = get(hwindslider,'Value');

        set(hwcurr,'Visible','on','String',num2str(W))

        T = get(htempslider,'Value');

        set(htcurr,'Visible','on','String',num2str(T))

        wcf = 35.7+.6*T-35.7*WA0.16+.43*T*WA0.16;

        set(hwcf,'String',['WCF = ',num2str(wcf)))

    end

end