Please answer this question using matlab
MATLAB Question
You are given the function
%MATLAB PROGRAM MINIMISING f(x1,x2) USING GENETIC ALGORITHM
WITHOUT
%CONSTRAINTS
clc
clear
f = @(x) 2.*x(1).^2 - 2.*x(1).*x(2) + 2.*x(2).^2 - 6.*x(1) +
6;
xmin = -4; xmax = 4;
num_vars = 2; % number of variables = 2 (x1 and x2)
%applying ga
[X,fmin] = ga(f,num_vars,[],[],[],[],xmin,xmax,[],[])
%solutions
x1 = X(1)
x2 = X(2)
minimum_f_value = fmin
%MATLAB PROGRAM MINIMISING f(x1,x2) USING GENETIC ALGORITHM A CONSTRAINT
function [c,ceq ] = constraint(x)
ceq = x(1)+x(2)-2; %equality constraint x1+x2 = 2
c = []; %inequality constraint
end
-------------------------
clc
clear
f = @(x) 2.*x(1).^2 - 2.*x(1).*x(2) + 2.*x(2).^2 - 6.*x(1) +
6;
xmin = -4; xmax = 4;
num_vars = 2;
%applying ga
[X,fmin] = ga(f,num_vars,[],[],[],[],xmin,xmax,@constraint,[]);
%solutions
x1 = X(1)
x2 = X(2)
minimum_f_value = fmin
%MATLAB PROGRAM PLOTTING CONTOURS OF f(x1,x2)
close all
clear
clc
f = @(x1,x2) 2.*x1.^2 - 2.*x1.*x2 + 2.*x2.^2 - 6.*x1 + 6;
x1 = linspace(-4,4);
x2 = linspace(-4,4);
[X1,X2] = meshgrid(x1,x2);
F = f(X1,X2);
num_contours = 100;
figure
[C,h]=contour(X1,X2,F,num_contours)
title('contour plot of f(x1,x2) = 2*x1^2 - 2*x1*x2 + 2*x2^2 - 6*x1
+ 6')
xlabel('x1'),ylabel('x2')
%clabel(C,h) % show contour levels (values)
COMMENT DOWN FOR ANY QUERY RELATED TO THIS ANSWER,
IF YOU'RE SATISFIED, GIVE A THUMBS UP
Please answer this question using matlab MATLAB Question You are given the function
Please answer this question using Matlab: Write a matlab function to generate and plot a sine wave at a specified frequency having at least 10 cycles, for this case the amplitude will represent voltage. Your sine wave should have a positive going zero crossing at T=0. Make sure your plot has at least 25 samples per cycle. Make sure the plot is with respect to time. Your function needs to return your generated samples and time vector. The frequency will...
MatLab question, please answer in matlab. %{ Write a function that prints the area and circumference of a circle for a given radius. Only the radius is passed to the function. The function does not return any values. The area is given by pi*r^2 and the circumference is 2*pi*r. The function is called areaCircum. Example: areaCircum(input value) %} % Place your function call here
MATLAB QUESTION Find the answer for the given application of first-order differential equation using MATLAB. NOTE: Screenshot the MATLAB ENVIRONMENT together with the CODES and FINAL ANSWERS. PLEASE SOLVE USING MATLAB CODE! PLEASE SOLVE USING MATLAB CODE! PLEASE SOLVE USING MATLAB CODE! A racquetball is hit straight upward with an initial velocity of 2m/s. The mass of a racquetball is approximately 0.0427 kg. Air resistance acts on the ball with a force numerically equal to 0.50, where v represents the...
MATLAB QUESTION Find the answer for the given application of higher order differential equation using MATLAB. NOTE: Screenshot the MATLAB ENVIRONMENT together with the CODES and FINAL ANSWERS. PLEASE SOLVE USING MATLAB CODE! PLEASE SOLVE USING MATLAB CODE! PLEASE SOLVE USING MATLAB CODE! Assume an object weighing 2 lb stretches a spring 6 in. Find the equation of motion if the spring is released from the equilibrium position with an upward velocity of 16 ft/sec. What is the period of...
please answer the question using matlab Problem 3. (you need to include your matLab commands to receive any point, and be sure your answer is valid to at least two decimal places). Use the zooming technique to find solutions of the equation 8- 3sin(x)
please answer this in matlab so it can match the function. thank you - L - - - - - -2 t (s) Entire an equivalent function for the plot shown here using the step function, u(t)
Please answer question on MATLAB showing work and the script. Thank you. Create a function M-ile that will implement a for loop to perform the tollowing tasks for a random input array, tt x. Count how many elements are greater than an arbitrary integer and display these values as well as the count using fprintf. loop to perform the following tasks Create a function M-ile that will implement a for l for a random input array, x. Calculate the arithmentic...
Matlab please Using the X and Y values below, write a MATLAB function SECOND_DERIV in MATLAB. The output of the function should be the approximate value for the second derivative of the data at x, the input variable of the function Use the forward difference method and interpolate to get your final answer. X=[1,1.2,1.44,1.73,2.07,2.49,2.99,3.58,4.3,5.16,6. 19,7.43,8.92, 10.7,12.84,15.41,18.49]; Y=[18.89,19.25,19.83,20.71,21.96,23.6,25.56,27.52,28.67,27.2,19.38,-2.05,-50.9,-152.82,-354.73,-741.48,-1465.11];
Using Matlab can you please write the code for question 5. Display the zl and 22 results using the table function. 5. Create an anonymous function (name it perm) to determine how many arrangements of a subgroup n are possible from a total group size of m when the order is important (permutations). Test the function with m= 10 and n 3 . Use an fprintf statement to display the answer
specify Output, please. 6. Create a MATLAB script to integrate the given function using the numerical scheme called Trapezoid's Rule. a. f(x)- xe* +3x1+2x-1 and find for with h 0.1, 0.01 and 0.001 Input: (copy and paste the MATLAB or Scilab command in the following box)