MATLAB Answers

a small problem with linspace

21 views (last 30 days)
sofiane benhamza
sofiane benhamza on 25 Sep 2020 at 1:18
Commented: sofiane benhamza on 25 Sep 2020 at 2:09
a =
11981420 % length of an audio which i need
>> g=linspace(1,200,5); % what we all know about linspace command
>> length(g)==5
ans =
1
>> s=linspace(1,0,a/40); % s should have a/40 element
>> length(s)==a/40
ans =
0 % but , why false??! ,

  0 Comments

Sign in to comment.

Accepted Answer

Adam Danz
Adam Danz on 25 Sep 2020 at 1:31
Edited: Adam Danz on 25 Sep 2020 at 1:35
11981420 is not divisible by 40.
11981420/40
ans =
2.9954e+05 % = 299535.5
size(s)
ans =
1 299535
299535 == 299535.5
ans =
logical
0

  1 Comment

sofiane benhamza
sofiane benhamza on 25 Sep 2020 at 2:09
i didn't realise that , thank you :- )

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by