I am solving a ODE as follows:
import numpy as np
import scipy as sp
import math
from math import *
from scipy.integrate import odeint
import matplotlib.pyplot as plt
def g(y, x):
y0 = y[0]
return x #formula##
# Initial conditions on y, y' at x=0
init = 0 #value##
# First integrate from 0 to 100
xplotval=np.linspace(4,8,4) #linspacefunction
print(xplotval)
I am getting output as:
[[ 7. ]
[ 5.76455273 ]
[ 5.41898906 ]
[ 6.49185668 ]]
I'd like to output a single dimensional array as follows:
[7., 5.76455273, 5.41898906, 6.49185668]
How can I?
答案 0 :(得分:1)
Maybe you want flatten
:
print(xplotval.flatten())
Unless you actually want the transposed vector, which you would get with numpy.transpose
:
print(np.transpose(xplotval))
答案 1 :(得分:0)
You can simply use list comprehension, something like:
oneD = [l[0] for l in xplotval]