Python & Matlab Difference in Matrix Calculation for Nesting Loop -


import numpy np  x=[ 2061075.875,  2061801,  2061154.25,  2061605.75,  2061314.375] y=[ 10638640,  10639060,  10638727,  10639118,  10638802] st=[ 73.92976,  71.13528,  64.40809,  71.80971,  72.72918] l=[ 254.96384,  239.15473,  200.20001,  218.91659,  185.49989]  deltal=10  n=np.floor(np.divide(l,deltal))  in range(0,len(x)):      if (int(n[i]/2)==n[i]/2):          px_down = np.zeros((len(x),max(np.floor(n/2))))         py_down = np.zeros((len(x),max(np.floor(n/2))))          j in range(0,int(n[i]/2)):                  px_down[i,j]=x[i]-(deltal*j)*np.sin(st[i]*np.pi/180)                 py_down[i,j]=y[i]-(deltal*j)*np.cos(st[i]*np.pi/180)      else:          px_down = np.zeros((len(x),max(np.floor(n/2))))         py_down = np.zeros((len(x),max(np.floor(n/2))))          j in range(0,int((n[i]-1)/2)):                  px_down[i,j]=x[i]-(deltal*j)*np.sin(st[i]*np.pi/180)                 py_down[i,j]=y[i]-(deltal*j)*np.cos(st[i]*np.pi/180) 

the result of px_down , y_down strange , many zeros in these 2 matrix. using matlab, obtain that:

2061066.26576935  2061056.65653871    2061047.04730806    2061037.43807742    2061027.82884677    2061018.21961613    2061008.61038548    2060999.00115484    2060989.39192419    2060979.78269355    2060970.17346290    2060960.56423225 2061791.53715368  2061782.07430735    2061772.61146103    2061763.14861471    2061753.68576838    2061744.22292206    2061734.76007574    2061725.29722942    2061715.83438309    2061706.37153677    2061696.90869045    0 2061145.23106473  2061136.21212947    2061127.19319420    2061118.17425893    2061109.15532367    2061100.13638840    2061091.11745313    2061082.09851787    2061073.07958260    2061064.06064733    0   0 2061596.24975030  2061586.74950061    2061577.24925091    2061567.74900121    2061558.24875151    2061548.74850182    2061539.24825212    2061529.74800242    2061520.24775272    2061510.74750303    0   0 2061304.82587875  2061295.27675750    2061285.72763625    2061276.17851501    2061266.62939376    2061257.08027251    2061247.53115126    2061237.98203001    2061228.43290876    0   0   0 

does has idea of solving problem? help!!!

you overwrite matricies. try this:

import numpy np  x=[ 2061075.875,  2061801,  2061154.25,  2061605.75,  2061314.375] y=[ 10638640,  10639060,  10638727,  10639118,  10638802] st=[ 73.92976,  71.13528,  64.40809,  71.80971,  72.72918] l=[ 254.96384,  239.15473,  200.20001,  218.91659,  185.49989]  deltal=10  n=np.floor(np.divide(l,deltal))  px_down = np.zeros((len(x),max(np.floor(n/2)))) py_down = np.zeros((len(x),max(np.floor(n/2))))  in range(0,len(x)):      if (int(n[i]/2)==n[i]/2):            j in range(0,int(n[i]/2)):                  px_down[i,j]=x[i]-(deltal*j)*np.sin(st[i]*np.pi/180)                 py_down[i,j]=y[i]-(deltal*j)*np.cos(st[i]*np.pi/180)      else:            j in range(0,int((n[i]-1)/2)):                  px_down[i,j]=x[i]-(deltal*j)*np.sin(st[i]*np.pi/180)                 py_down[i,j]=y[i]-(deltal*j)*np.cos(st[i]*np.pi/180) 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -