Question #60418

Q. Write any two programs of MATLAB.

Expert's answer

Answer on Question #60418 - Programming & Computer Science - MATLAB

Question:

Write any two programs of MATLAB.

Solution:

1) The code for the program, which performs the calculation a^2+b^2:


clear
clc
disp('This program performs the calculation a^2+b^2');
%asking for a
prompt = 'Please, enter a:';
a = input(prompt);
%asking for b
prompt = 'Please, enter b:';
b = input(prompt);
disp(['The result is: ' num2str(a^2+b^2)]);


2) The code for the program, which greets the customer:


clear
clc
%asking for name
prompt = 'Please, enter you name:';
name = input(prompt, 's');
disp(['Hi, ' name '! It is nice to see you!']);


Results:

1) This program performs the calculation a^2+b^2

Please, enter a: 2

Please, enter b: 3

The result is: 13

2) Please, enter you name: Peter

Hi, Peter! It is nice to see you!

https://www.AssignmentExpert.com

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS