error using plot: Data must be numeric, datetime, duration or an array convertible to double.

5 次查看(过去 30 天)
I keep getting the error :
Error using plot
Data must be numeric, datetime, duration or an array convertible to double.
Error in acchirp482assign2 (line 38)
plot(t,ac);
But I have no idea what is wrong with the code: please help this assignment was due yesterday :(
.
  3 个评论
the cyclist
the cyclist 2020-2-13
Walter has given you the correct answer.
But, for future reference, that file you uploaded is still just a picture of your code, which is pretty useless. It's much better to upload the code (for example in an *.m file) or paste the actual text here. That way, if we can grab the code for testing, without having to type it all in ourselves.
Walter was able to notice your mistake just by looking at the code, but often that is not possible, and we need to run your code.

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2020-2-13
You are not assigning to ac in the posted code.
Your t is a vector. Your if is testing a vector. A vector if test is only true if all elements of it are nonzero (true). Your vector if is not all true and your vector else if is not all true, so you do not assign to ac.
You should look at logical indexing.

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by