translate matlab to igor
zhen
I am trying to translate matlab to igor and I really need some one to help me out. Thanks in advance!!!
the matlab content is as below:
pin = zeros(numel(n), numel(theta));
taun = zeros(numel(n), numel(theta));
mu = cos(theta);
pin(1,:) = 1;
pin(2,:) = 3*mu;
taun(1,:) = mu;
taun(2,:) = 6*mu.^2 - 3;
for in=3:n(end)
pin(in,:) = (2*in - 1)/(in - 1)*mu.*pin(in-1,:) ...
- in/(in - 1).*pin(in-2,:);
taun(in,:) = in*mu.*pin(in,:) - (in + 1)*pin(in-1,:);
end
I have tried igor for the first few lines above but I'm not sure if it ok and how to do for the rest........
Make/O/N=(n,theta) pin
Make/O/N=(n,theta) taun
Make/O/N=(theta) mu= cos(theta)
pin(0,0)=1 //pin(1,:) = 1;
pin(1,0)=3*mu//pin(2,:) = 3*mu;
tau(0,0)=mu//taun(1,:) = mu;
tau(1,0)=6*mu^2-3
The expression
pin(1,:) = 1;
for example translates to
as Igor uses zero-based indizes. For an explanation see
DisplayHelpTopic "Indexing and Subranges"
.If new to Igor I'd spend some time studying
June 16, 2014 at 05:42 am - Permalink
Thank you very much. The topic is very helpful. but I think I use pin(0,0)=1, which is same as pin[0][]=1?
June 16, 2014 at 08:59 am - Permalink
As near as I can tell, pin(0,0) = 1 is either undefined or pin[0][0] = 1. The User Manual is a good thing to read at this point.
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
June 16, 2014 at 09:20 am - Permalink
Thank you very much, i see. if it is in function, I will use pin[0][] or x2pnt .
June 16, 2014 at 09:31 am - Permalink