0% found this document useful (0 votes)
4 views

MATLAB Programming

Uploaded by

annexshaw26
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

MATLAB Programming

Uploaded by

annexshaw26
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

1.

temperature = input('Please enter the temperature: ');


units = input('Please enter the units of Temperature (C or F): ','s');
if (units == 'F' || units == 'f')
converted = (temperature-32)*(5/9);
convertedto = 'C';
elseif (units == 'C' || units == 'c')
converted = temperature*(9/5) + 32;
convertedto = 'F';
else
fprintf('\nYou have given a wrong input\n')
fprintf('The program will restart again\n')
fprintf('----------RESTART - FCF.M --------- \n\n')
fcf
end
fprintf('%.2f %s = %.2f %s\n',temperature,
upper(units),converted,convertedto)

2.
x=input('Enter a number');
t=1;
for i=1:x
t=t*i;
end
disp(t)

3.
N = input('Enter a number')
s = (-1)^N;
if s == -1
disp('N is odd')
else
disp('N is even')
end

4.
name = 'Sandeep';
x = input('Number of times to display your name');
for i = 1:x
display(name);
end

You might also like