Finding the indicies of the cell element
조회 수: 1 (최근 30일)
이전 댓글 표시
Hey all.
I asked this question already, But I didn't get the solution I intended.
I have a cell array
A = { [ 2 4 6] ['Air'; 'oil'; 'Metal']}
Here I am putting a part of my code.
for count = 1:n
if whichnode = find(X{1} == count, 1)
if ~isempty(whichnode)
whichnode = count;
% here I need to find the indicies of the count, which(number) will be there in matrix of the cell A{1}, I know using this, for an example if count = 4, it's indicies is A{1}(1,2). %This I can write manually, but I can't write it for each input. So I need to find the indicies for any input in A{1} again. One more example, if count = 9, it's indicies should be given automatically before the plot function.
plot(f, T1, 'DisplayName', A{2})
end
end
end
Here my Idea is to get the indices of the count in the matrix of the cell array, before the solver enter the built in function plot.
The reason is, using that indicies, I can display the name of the plot easily with my idea.
I don't know whether it is possible or not!. But If we get the idea, there should be a way to do it. I need that way.
Any suggestions and answered are most welcomed!
Thanks in advance
댓글 수: 8
Jan
2019년 7월 4일
@surendra kumar Aralapura mariyappa: X{2} = ['Air'; 'Oil';' Material'] is no valid Matlab syntax and this has been mentioned repeatedly already. You do not mention, what you want to achieve but repeat to post this strange piece of code. So how can we help you?
Maybe you want this instead:
X{1} = {'Air'; 'Oil';' Material'}
% ^ ^ Curly braces, not square brackets
Or
X{1} = ["Air"; "Oil";" Material"]
% ^ ^ ^ ^ ^ ^ double quotes for strings
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!