How can I save the total number of each selection from a listdlg using num2str?
2 views (last 30 days)
Show older comments
Hi all,
I want to display how many times each choice of a list has been selected in the xlabel plot.
This is the code for the xlabel:
f1=figure(1);
set(f1,'units','normalized','position',[0 0 1 1],'NumberTitle','on','ToolBar', 'None');
f1.WindowState = 'maximized';
hold on;box on; grid on;
plot(x,y,'b');
ylabel('Amplitud (pA)');
xlabel(['Time (s)' ' foot-Spike: ' num2str(mNum) ' Another event (Flicker): ' num2str(mNum)...
' Spike (Kiss&Run): ' num2str(mNum) ' Null event: ' num2str(mNum) ])
axis([x(1) x(length(x)) min(abs(y)) max(y)]); % Update plot
title('Select two points around a ROI', 'interpreter','none');
ylim([-100 200]);
This is the code for the list:
list = {'Foot Signal of the current spike','Another event (Flicker)',...
'Spike (Kiss&Run)','Null event','Redo de selecction'};
result = listdlg('PromptString',{'So far ' num2str(mNum) ' regions were measured'}, 'SelectionMode','single','ListString',list);
if result==1
mNum = mNum+1;
save([mainDir 'Spike No' num2str(mNum,'%d') '.mat'], 'T','I')
elseif result==2
mNum = mNum+1;
save([mainDir 'Flicker No%d' num2str(mNum,'%d') '.mat'], 'T','I');
elseif result==3
mNum = mNum+1;
save([mainDir 'Spike Kiss&Run' num2str(mNum,'%d') '.mat'], 'T','I');
...
end
When I write, for example, num2str(list{1}), Matlab says Undefined variable list. I tried almost every option but I cannot get the solution.
I guess the problem is that list is a string. Therefore, num2str is not correct, but I am not sure.
Update:
I set the varible list as a global variable
global list
I've change the xlabel code:
xlabel(['Time (s)' ' foot-Spike: ' num2str(list==1)])
And this is the Matlab error:
Undefined operator '==' for input arguments of type 'cell'.
Error in spikes_detection_listdlg (line 34)
xlabel(['Time (s)' ' foot-Spike: ' num2str(list==1)])
May you help me?
Update (25.01.2020):
I found the way to add +1 at each spike type at the xlabel, BUT after the first slection, the counter reset. Therefore, the num2str does not exceed number 1.
global fs
global fl
global KnR
global null
f1=figure(1);
set(f1,'units','normalized','position',[0 0 1 1],'NumberTitle','on','ToolBar', 'None');
f1.WindowState = 'maximized';
hold on;box on; grid on;
plot(x,y,'b');%axis tight;
ylabel('Amplitud (pA)');
xlabel(['Time (s)' 'foot-Spike: ' num2str(fs) ' Flicker:' num2str(fl)])
axis([x(1) x(length(x)) min(abs(y)) max(y)]); % Update plot
list = {'Foot Signal of the current spike','Another event (Flicker)',...
'Spike (Kiss&Run)','Null event','Redo de selecction','Close all'};
result = listdlg('PromptString',{'So far ' num2str(mNum) ' regions were measured'}, 'SelectionMode','single','ListString',list);
fs=result==1;
fl=result==2;
KnR=result==3;
null=result==4;
if result==1
mNum = mNum+1;
fs= fs+1;
save([mainDir 'Spike No' num2str(mNum,'%d') '.mat'], 'T','I')
elseif result==2
mNum = mNum+1;
fl=fl+1;
save([mainDir 'Flicker No%d' num2str(mNum,'%d') '.mat'], 'T','I');
elseif result==3
mNum = mNum+1;
KnR=KnR+1;
save([mainDir 'Spike Kiss&Run' num2str(mNum,'%d') '.mat'], 'T','I');
...
end
0 Comments
Answers (1)
KALYAN ACHARJYA
on 23 Jan 2020
xlabel(['Time (s)' ' foot-Spike: ',list{i}])
Here i is any number, not larger than length of list
2 Comments
See Also
Categories
Find more on Electrophysiology in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!