Hi!
I'm trying to pass values from a figure to another, in order to modify the scale of my axes. At the end, the aim of the program is to visualize EMG datas, with different option but no real data processing.
So the code is the following:
function Appel
global y l c t d;
name=0;
f=figure('units', 'pixels',...
'position', [300 300 300 300],...
'MenuBar', 'none');
ml=uimenu(f, 'Label', 'Load',...
'Callback', {@meme});
a=axes('units', 'pixels',...
'position', [10 100 280 180],...
'tag', 'axe');
gogo=uicontrol('style', 'pushbutton',...
'position', [10 10 50 30],...
'String', 'set axe',...
'callback',{@go});
S.fh=figure('units', 'pixels',...
'position', [100 100 200 150],...
'MenuBar', 'none',...
'visible', 'off');
S.duree=uicontrol('style', 'edit',...
'position', [10 90 50 30],....
'String', 'Durée');
S.valide=uicontrol('style', 'pushbutton',...
'position', [10 30 50 30],...
'String', 'Valide',...
'callback', {@recup});
function[]=meme(varargin)
[name path]=uigetfile('*.txt', 'open emg');
while name ==0
pause(0.1);
disp('wait for it...');
end
disp(name);
y=load(name);
axes(a);
plot(y);
[l c]=size(y);
set(S.fh, 'visible', 'on');
end
function[]=recup(varargin)
d=get(S.duree, 'String');
t=linspace(0,d,l);
end
function[]=go(varargin)
axes=a;
plot(y, t);
end
First i'm loading a .txt file with the data. Then another figure appears, in order to give to the axes the X limit max. I want my axe graduate from 0 to an X value. But despite it seems to work when I'm doing it in command line, here I have the following error msg:
">> Appel
sample.txt
Error using .*
Matrix dimensions must agree.
Error in linspace (line 30)
y = d1 + (0:n1).*(d2 - d1)/n1;
Error in Appel/recup (line 61)
t=linspace(0,d,l);
Error while evaluating uicontrol Callback"
unfortunately, I can't send you the sample.txt file, it's 10Mo of :
1.6484212e+01
1.5100857e+01
3.9246697e+01
4.3396763e+01
4.6414993e+01
4.6289233e+01
5.6853038e+01
5.7859115e+01
Thank you by advance for your help!

 채택된 답변

dpb
dpb 2015년 9월 23일

0 개 추천

...
d=get(S.duree, 'String');
t=linspace(0,d,l);
d is a character variable of length of however many characters it is; you likely mean
d=str2num(get(S.duree, 'String'));
t=linspace(0,d,l);

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

질문:

2015년 9월 22일

답변:

dpb
2015년 9월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by