function for if loop
显示 更早的评论
Hello guys,
I would like to create a function that I could use it in elsewhere script in the future. Here is what I've came up with:
function output = name()
output = [?????? ??????]
for k = 1:size(table)
if table.("My Column1")(k) == "Manchester City"
ChampionsYears(k) = 2012;
elseif table.("My Column2")(k) = "Manchester City"
ChampionYears(k) = 2012;
end
.
.
.
end
end
I have table with 10 columns, and I want the function (and loop) to check through the table (row-wise) if any string in the cell is "Manchester".
If so, assign the value of 2012 to "Champion Years". I want the function to have no inputs, and to be like so: displayed message (any) in command window and assign value of 2012 to Champion Years. Could you please modify this piece of code?
Regards
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!