help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: having difficulty using a for loop to solve an equation


From: Kire Pudsje
Subject: Re: having difficulty using a for loop to solve an equation
Date: Tue, 20 Jun 2017 07:17:29 +0200



On Tue, Jun 20, 2017 at 2:26 AM, shankara naryana <address@hidden> wrote:
got rid of i and j my code looks like this:

%Vectorization
clc;
clear;
a=[1 2 3 4 5];      %array created per spec
x=a;                %array created per spec
b=[-2 -1 0 1 2];    %array created per spec
y=5-2.*b;           %array created per spec 
z=(y+x).^3;         %formula to be solved in loop
for m=a
  t=z
end

Actually you already wrote the vectorized form. There is no need for the for loop anymore
For the for loop solution, you would need to calculate the solution for each index separately.

I do not know if my other mail came through. There are network problems in the Netherlands.
But I think the assignment is ill-formed.
Purely from a methematical perspective, only z_1 and z_2 are defined.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]