Error: 'Matrix dimensions must agree' even when using a scalar to multiply with Matrix.
Show older comments
Hello, I am actually multiplying the matrix with a scalar, if I however take the user input for the scalar it displays error as :* Error using '*' Inner matrix dimensions must agree.*
Part of my code that uses this is:
scale = ('Enter the scale for noise to be added to the signal, scale = ');
n=linspace(0,2*pi,N);
s=sin(2*pi*n);
v=randn(1,N);
x=s+v*scale;
However if I implicitly mention the scalar in m-file it works perfectly. The following code works:
scale = 0.2;
n=linspace(0,2*pi,N);
s=sin(2*pi*n);
v=randn(1,N);
x=s+v*scale;
I am a noob, so please be gentle. Any help would be appreciated. Thank you!
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!