We will do some MATLAB programming exercises about in-line function, online help
ID: 2081658 • Letter: W
Question
We will do some MATLAB programming exercises about in-line function, online help and plotting graphs 1. Creating and using Inline function F = inline ('function formula') Ex.>>Fx = inline('x^2+sin(x)); >>Fx(pi) Using inline function to calculate the area of circles with radius of 2, 5, 20, respectively. Using on-line help >>help a) help with a function name, ex, >>help lang b) look for, the keyword search >>look for determinant >>look for eigenvalue Calculate the determinant and eigenvalue of the following matrix A = [1 0 -1 2 2 0 3 1 2], c) help deskExplanation / Answer
%Q.1 code
%matlab code to calculate area of circle with given radius
clc;
clear all;
close all;
f=inline('pi*r^2'); %area of circle=pi*radius^2
%for radius=2,area of circle is:
fprintf('area of circle ,when radius is 2')
f(2)
%for radius=2,area of circle is:
fprintf('area of circle ,when radius is 5')
f(5)
%for radius=2,area of circle is:
fprintf('area of circle ,when radius is 20')
f(20)
output:
area of circle ,when radius is 2
ans =
12.5664
area of circle ,when radius is 5
ans =
78.5398
area of circle ,when radius is 20
ans =
1.2566e+03
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.