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]) Feb 13, 2020 in Python 7,631 views

## 1 answer to this question.

0 votes

Hey @Giorgio,

You can try this hope this will resolve your error.

```import numpy as np

N=0

C=0

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])

print(N)``` answered Feb 18, 2020 by
• 65,910 points

0 votes
1 answer

## Python Error ""ValueError: could not broadcast input array from shape (4) into shape (1000)""

There are better ways of achieving the ...READ MORE

+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

0 votes
1 answer

## ValueError: could not broadcast input array from shape (360,270,3) into shape (360,280,3)

Hi@akhtar, In the above error it shows could not ...READ MORE

0 votes
0 answers

## ValueError: could not broadcast input array from shape (224,224,9) into shape (224,224)

img_shape = 224 test_data = [] test_labels = [] for ...READ MORE

0 votes
2 answers

## how can i randomly select items from a list?

You can also use the random library's ...READ MORE

+1 vote
2 answers

## how can i count the items in a list?

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

0 votes
0 answers

## how do i use the enumerate function inside a list?

can you give an example using a ...READ MORE

+5 votes
6 answers

## Lowercase in Python

You can simply the built-in function in ...READ MORE

+1 vote
5 answers

## Python error "ERROR: Could not find a version that satisfies the requirement PyQt4 (from versions: none)"

You cannot install PyQt directly from pip. ...READ MORE

0 votes
1 answer

## ERROR: Could not find a version that satisfies the requirement pythoncom (from versions: none) ERROR: No matching distribution found for pythoncom

Hi, @John,  Regarding your query, I guess you ...READ MORE