Looking to write a code which utilises a formula to solve an equation

1 Ansicht (letzte 30 Tage)
Sinclair Song
Sinclair Song am 13 Apr. 2020
Bearbeitet: Sinclair Song am 15 Apr. 2020
clc
clear all
close all
AF = @(x) x^3-4x^2-1; % function equation
xR(R/2) = 46/x + 5(x-3); % iterative formula
x3 = 1;
Very new to MATLAB and was wondering how I would go about creating an iteration to output solutions to the problem.
  2 Kommentare
Mehmed Saad
Mehmed Saad am 13 Apr. 2020
Bearbeitet: Mehmed Saad am 13 Apr. 2020
  1. what is xRk
  2. For how many iterations of R you want to run the formula
  3. what is the purpose of AF function in this code?
Sinclair Song
Sinclair Song am 13 Apr. 2020
1. My mistake, it's just meant to be xR, I've corrected it now
2. I'd say 100 to get possible solutions
3. AF is the function equation I'm trying to solve using the values generated from the iterative equation

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Mehmed Saad
Mehmed Saad am 13 Apr. 2020
k=100;
xR = zeros(1,k);
xR(1) =2; % Initial Guess
for i=2:k
xR(i) = 1+ (1/xR(i-1)); % iterative formula
end
Now xR is an array which contains the value for 100 iteration where each iteration value depends on previous one
  6 Kommentare
Sinclair Song
Sinclair Song am 13 Apr. 2020
Bearbeitet: Sinclair Song am 13 Apr. 2020
Oh so it turns out the solution is too small to pick up, if I'm interpretting that correctly? How would I go about indexing an array? Thanks for all the guidance!
Mehmed Saad
Mehmed Saad am 13 Apr. 2020
Try using matlab help and google
in this way you can learn matlab faster

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by