Access over 20 million homework & study documents

Matlab Solution

Content type
User Generated
Subject
MathLab
School
SUNY at Stony Brook
Type
Homework
Rating
Showing Page:
1/2
MatLab Program:
clear;
clc;
%n=input('Enter the number of equations:');
n=4;
f=cell(n,1);
%x(1)=delta P
%x(2)=w1
%x(3)=w3
%x(4)=w
f{1}=@(x) x(1)-810+25*x(2)+3.75*x(2)^2;
f{2}=@(x) x(1)-750+65*x(3)+30*x(3)^2;
f{3}=@(x) x(1)-6.0*x(4)^2-500.0;
f{4}=@(x) x(2)+x(3)-x(4);
% initial guess
x=[700;2;1.0;4.5];
% tolerance
tol=1e-5;
% delta used in finding derivation
delta=0.0001;
Er=Inf;
J=zeros(n,n);
F=zeros(n,1);
iteration=0;
while Er>tol
for i=1:n
for j=1:n
X=x;
X(j)=X(j)+delta;
J(i,j)=(1/delta)*(f{i}(X)-f{i}(x));

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/2

Sign up to view the full document!

lock_open Sign Up
Unformatted Attachment Preview
MatLab Program: clear; clc; %n=input('Enter the number of equations:'); n=4; f=cell(n,1); %x(1)=delta P %x(2)=w1 %x(3)=w3 %x(4)=w f{1}=@(x) x(1)-810+25*x(2)+3.75*x(2)^2; f{2}=@(x) x(1)-750+65*x(3)+30*x(3)^2; f{3}=@(x) x(1)-6.0*x(4)^2-500.0; f{4}=@(x) x(2)+x(3)-x(4); % initial guess x=[700;2;1.0;4.5]; % tolerance tol=1e-5; % delta used in finding derivation delta=0.0001; Er=Inf; J=zeros(n,n); F=zeros(n,1); iteration=0; while Er>tol for i=1:n for j=1:n X=x; X(j)=X(j)+delta; J(i,j)=(1/delta)*(f{i}(X)-f{i}(x)); end F(i,1)=-f{i}(x); end Aug=[J F]; for i=1:1:n-1 for j=i+1:n Aug(j,:)=Aug(j,:)-(Aug( ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Anonymous
Very useful material for studying!

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4