How can I multiply two different sized objects?

1 次查看(过去 30 天)
%Matrix dimensions must agree.
A = 1;
pas = 1/1000;
t=-10:pas:10;
k=10;
omega = -k*pi/A:1/10:k*pi/A;
x=omega.*t;
%The error appears on the last line where x is. how can i multiply them?

采纳的回答

madhan ravi
madhan ravi 2019-1-8
omega = linspace(-k*pi/A,k*pi/A,numel(t)); % change your line to this

更多回答(1 个)

Totanly
Totanly 2019-1-8
you can't multiply two different sized vectors. Follow the matrix multiplication rules.
if A=first matrix and B=second matrix
size(A) should be Size(B) for element by element multiplication;
no of columns of A= no of rows of B for matrix multiplication

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by