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?
0 个评论
采纳的回答
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 Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!