Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: code problem
Replies: 2   Last Post: Jun 19, 2012 8:11 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Jonathan Allan

Posts: 116
Registered: 12/7/04
code problem
Posted: Jun 19, 2012 7:22 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi,
I'm trying to solve a simple function iteratively. My code is as follows...
d2=3;
z=0.0192;
newvar=zeros(1,1552);
for n = 1:.1:156
newvar(n) = (d2./n).*tanh((2*pi*d2)./n);
end

The first issue is that Matlab objects to this and gives me the message "Attempted to access newvar(1.1); index must be a positive integer or logical."

Ultimately, what I'm trying to find is the n value that equals the solution to the equation, which is indicated by z. I was planning to do this by using find, once I have run the loop.

What am I doing wrong?

Thanks
Jon



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.