ValueError: could not broadcast input array from shape (4,1) into shape (4)

0 votes
This code produces this error of broadcasting and I don't understand why. N is a number, C is a matrix 4x4, xvec_tra an array 4x1 and the result x should be a matrix 4xN.

x=np.zeros(shape=(4,int(N)), dtype=np.float64)
for i in range(0, int(N/2)):
    if i == 0:   
        x[:,0]=C * xvec_tra
        print(x[:,0])
else:
    x[:,i]=C*x[:,i-1]
    print(x[:,i])
5 days ago in Python by Giorgio
• 120 points
59 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Python

0 votes
1 answer
+1 vote
0 answers

ValueError: could not broadcast input array from shape (2) into shape (5)

I was implementing gillespie algorithm and when ...READ MORE

Dec 23, 2019 in Python by anonymous
• 130 points

reshown Jan 13 by Kalgi 319 views
+3 votes
2 answers

how to print array integer without [] bracket in python like result = 1,2,3,4,5

Hey @abhijmr.143, you can print array integers ...READ MORE

answered Aug 4, 2018 in Python by Omkar
• 68,940 points

edited Aug 8, 2018 by Omkar 1,960 views
+1 vote
3 answers
0 votes
1 answer
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 630 views
0 votes
0 answers
+4 votes
6 answers