Repeating a function n times with different values from a vector
Show older comments
I have quite a big problem and I hope that anyone could help me.
I'm using Newton Pharson to iterate two equations with a vector x as input. Now I want to split the vector in different sections and calculate for every single section the equation and save the solutions in another new vector
Example what I mean:
x = [0.093,0.23,0.6,0.95,0.54,1]
Now I would calculate the equation for the value pairs of 0.093, 0.23 -> solution is saved to a matrix y = [2,3]
then for the next two value pairs of x (0.6 & 0.95) and save the two solutions to the matrix y = [2,3;1,2]
Does anyone have a solution to this problem?
clear all;
clc;
%% inputs:
x = [0.093,0.23,0.6,0.95,0.54,1];
% residuals
fun = @(b) ..... %enter the equation
%% solve
x0 = [3]; %initial guess
options = optimset('TolX',1e-12); % set TolX
for i =....
[b, resnorm, f, exitflag, output, jacob] = newtonraphson(fun, x0, options);
c = b +1;
end
Accepted Answer
More Answers (0)
Categories
Find more on App Building in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!