Finding the indicies of the cell element

2 次查看(过去 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 个评论
surendra kumar Aralapura mariyappa
@ Jan & Guillaume
Thank you for all your kind responses.
I found the answer by myself. one of your colleague gave me the hint on the other day. Now I remembered that. Finaaly I did it.
'How is this any different from your previous question for which you accepted my answer?'
Th difference is I need the specific name Like X{2} = ['Air'; 'Oil';' Material']. But vector dimensions is not correct. I just need to know how to fix it!
Below was my code with the help of Bob.
Jan
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 个)

产品


版本

R2014a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by