In: Computer Science
MATLAB is program
Respond fast please a quiz
Create a MATLAB script.
Using nested for loops, evaluate the multivariable function:
z = sin ( x ) cos ( y )
for
Display the matrix z
Cut and paste the following into a word doc and submit to this question.
%% Matlab code for Z = sin(x)cos(y)
clear all;
close all;
clc;
% x and y declaration
x=-4:1:4
y=-2:1:2
% z is created as empty vector and later values gets appended
z=[]
%% Nested For Loops for evaluation
for i=1:length(x)
for j=1:length(y)
z=[z sin(x(i))*cos(y(j))]
end
end
%% Display of the Result
disp(z)
The above picture talks about Matlab code as per Question.Code works well and satisfies all requirments.
The above picture talks about the output of code (z matrix)