error using zeros in matlab

er = zeros(1, .125*N); % eigth rest
qr = zeros(1, .25*N); % quarter rest
hr = zeros(1, .5*N); % half rest
tr = zeros(1, .75*N); % three-quarter rest
wr = zeros(1, N); % whole rest
I get the error Error using zeros Size inputs must be integers.
Error in pleasework (line 49) er = zeros(1, .125*N); % eigth rest
>>

4 个评论

When using zeros, the size should be an integer value. Please refer to the link below for more information.
@Esha Bhargava: you could put this as an answer, and I would vote for it.
so whats the final answer ?? did you manage to solve it ?
Jan
Jan 2017-10-4
编辑:Jan 2017-10-4
John's answer is clear enough. The solution is trivial: zeros creates an array, and therefore the number elements must be integers. It is not clear what zeros(1, 0.125*N) should do if N is not a multiple of 8.

请先登录,再进行评论。

 采纳的回答

John D'Errico
John D'Errico 2015-11-20
编辑:John D'Errico 2015-11-20

1 个投票

I wonder, what are the odds that N is not an integer multiple of 8?
Zeros requires integer arguments. READ THE ERROR MESSAGE! If N is not an integer multiple of 8, then when you multiply by 0.125, you get a non-integer. So you need to think about what size you really need for this vector. If I had to guess, you might want to round up or round down, but this is your code, so you are the one who knows what you wanted to do.

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by