fun applied to a loop
1 次查看(过去 30 天)
显示 更早的评论
Hi, I am struggling to apply my fun to a loop. Any tip? Here is my code:
function T=totalflow(x,N)
T(:)=x(1:N)+x(N+1:2*N);
end
%saved as totalflow.m
and main program:
inFlow = rand(10,3);
x0 = [inFlow; zeros(size(inFlow))];
[N,M] = size(inFlow);
T=totalflow(x0,N);
% this works for only one column on inFlow. I want to get T[10,3] like:
for i=1:M
T(:,i)=totalflow(x0(:,i),N);
end
%this does not work. Any tip? Thanks
0 个评论
采纳的回答
更多回答(1 个)
另请参阅
类别
在 Help Center 和 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!