MATLAB cannot call or index into a temporary array in for loop
3 次查看(过去 30 天)
显示 更早的评论
Hello Friends,
Here is my code:
M = {'a', 'b', 'c'};
for i = length(M)
M(i) = M(i)(M(i)~=0);
end
In other words, I am trying to get for each vector 'a', 'b', and 'c' the following in for loop:
a = a(a~=0);
b = b(b~=0);
c = c(c~=0);
I get the following error: "cannot call or index into a temporary array"
I will appreciate any advice.
回答(2 个)
Azzi Abdelmalek
2016-5-17
I don't know what you want, your example is not appropriate, comparing letters with 0!
A=[1 2 0 5 0 7]
B=A(A~=0)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!