nashynash
nashynash

Reputation: 375

Can we add a statement in between MATLAB codes?

Is it possible to add statements in between the codes.
For example: If I have a code like this,

r(:,1) = a(:,1) - a(:,2);

Then can I write it as,

r(:,1) = a(:,1)("this is a constant") - a(:,2)("this is a variable");

Upvotes: 0

Views: 79

Answers (2)

rst
rst

Reputation: 2724

Just as a sideremark to the very correct answer of sudomakeinstall2

In other programming languages, as e.g. Java you can do something like

myvar = 1 + /* some comment here */ 5;

Eventhough MATLAB knows something similar with %{ ending with %}, they only work for multiline comments, so in the end, sudomakeinstall2s answer is the best I can think of.

Upvotes: -1

Saeid
Saeid

Reputation: 4265

You need to comment those statements like this

r(:,1) = a(:,1) ... % this is a constant 
         - a(:,2); % this is a variable 

for more information read this

Upvotes: 4

Related Questions