I just started learning Matlab roughly an hour ago after being told I had to convert my rscript into Matlab. I wrote a conditional statement below and it does not work. The reason I believe is because it is not currently going line by line. data is a Matlab table. Here is my current code:
if data.Year == data.initYear
data.initY = -1
else
data.initY = 0
end
in R it was:
workable$saleYear <- ifelse(workable$year == workable$initYear, -1,0)
Any help would be appreciated
You want to do this in a vector. That way you don't need
for
loops orif
statements.