Dimensional error while running the code from matlab documentation
12 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Tommy
on 17 Apr 2020
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.
More Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!