Message Boards Message Boards

0
|
1654 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

How to define a function using the same loop variable

I was running this code and got the result as follows,

For[zr = 0.10, zr <= 0.50, zr = zr + 0.10, zx = Tanh[zr] Print[{zr, zx}]]

{0.1,0.781806 Null}

{0.2,0.099668 Null}

{0.3,0.197375 Null}

{0.4,0.291313 Null}

{0.5,0.379949 Null} Please tell me the solution.

2 Replies

Thanks a lot to you Marco. It has solved my problem.

Hi,

I do not fully understand what you want to achieve, but I guess that there is at least one semi-colon missing:

For[zr = 0.10, zr <= 0.50, zr = zr + 0.10, zx = Tanh[zr]; Print[{zr, zx}]]

which gives:

{0.1,0.099668}
{0.2,0.197375}
{0.3,0.291313}
{0.4,0.379949}
{0.5,0.462117}

Cheers,

Marco

POSTED BY: Marco Thiel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract