usukidoll
usukidoll

Reputation: 101

Matlab code with % symbol?

I'm supposed to replicate a model, but I have never came across a matlab code that has some code in the % area before. When I did simple assignments, it was just matlab code and anything with % means that it is just preformatted text which is just a description of the results I have. So, I was reading this paper and I'm wondering how does the code work when there are % inside? Doesn't that mean just text? What happens if the % is removed from the code?

enter image description here

I know it says not enough input arguments, so I let

eradode(a,b,ze,d,Ti,dt,s1,z1,r1) be

eradode(0.005,0.0095,0.0001,0.0001,10,1,500,0,0)

but it just does computation.

enter image description here

So, is this a computation only code? If I remove the % on plot(t,z) it would lead me to an error because t is unknown.

The original code is on the last few pages of this paper When Zombies Attack

I know I'm going to get why are you copying comments...here is my answer. I didn't feel comfortable doing the assignment because I thought that I should come up with my own, but my professor just told me to replicate the models from this paper and write the results in my own words. Well, I'm going to cite every sentence out just in case.

Upvotes: 0

Views: 226

Answers (1)

bilaly
bilaly

Reputation: 536

In Matlab the % symbol is used to indicate the start of a comment. The comments can be anywhere in the script. They are often used to describe what is happening as well as acting as an explanation. if the % symbol is removed then when you run the code matlab will read that line and attempt to run it, based on the libraries it has access to. if the text isn't actual code it will cause an error.

If you read the the description at the beginning of the function in the paper. It says that by using the defined inputs, a vector of solutions over a predetermined amount of time will be produced. So as to your question yes it is computation code. It also describes what the inputs should be in order for the function to operate correctly.

Upvotes: 1

Related Questions