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

5 views (last 30 days)
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 Comments
the cyclist
the cyclist on 13 Feb 2020
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.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 13 Feb 2020
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.

Community Treasure Hunt

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

Start Hunting!