Dimensional error while running the code from matlab documentation

12 次查看(过去 30 天)
fs = 1e3;
t = 0:1/fs:1;
x = [2 1 2]*sin(2*pi*[50 150 250]'.*t) + randn(size(t))/10;
in this code the dimension of the t mismatches with [50 150 200]'. how could i possibly get the output without dimesnsional error?

采纳的回答

Tommy
Tommy 2020-4-17
This code should run without error in R2016b and later due to implicit expansion, as t is a row vector and [50 150 200]' is a column vector. This is similar to
>> [1;2].*[1:10]
ans =
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
which might also be expected to result in an error.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by