Gui

Neue Frage »

Sourena Auf diesen Beitrag antworten »
Gui
Meine Frage:
Hallo,ich habe schon ein Gui,da habe ich Z.B. xa und xs und xe
ich habe auch schon ein anderes M.file. und in meinem M.file alles mit xa und xs und xe funktioniert. wie kann ich diese beide zusammen verbinden,wenn ich meine neue xa xs xe in meinem Gui verändere,die auch im Mfile verändert werden.

Liebe Grüße
Sourena

Meine Ideen:
mein gui :
clear all
close all
clc

breite=0.08;
hoehe=0.04;

xa=30;
xs=0.1;
xe=80;
ya=50;
ys=0.1;
ye=70;
ta=1000;
te=1000;
ts=1000;
start=0;
xb=5;% Min von X
xm=45;%max von x
test=0;


h.r1 = uipanel('units','normalized','Position', [0.05 0.5 0.90 0.4],...
'BackgroundColor', [0.8 0.8 0.8],...
'Title', 'Eingabe 1', 'FontSize', 11);
h.r2 = uipanel('units','normalized','Position', [0.05 0.1 0.90 0.4],...
'BackgroundColor', [0.8 0.8 0.8],...
'Title', 'Eingabe 2', 'FontSize', 11);
h.r3 = uipanel('units','normalized','Position', [0.33 0.52 0.35 0.35],...
'BackgroundColor', [0.8 0.8 0.8],...
'Title', 'X und Y werte bei Manual', 'FontSize', 8);
%h.axeBild = axes('units','normalized','OuterPosition', [0.05 0.05 0.34 0.85]);

for i=1
hc.xa=uicontrol('style', 'edit', 'units', 'normalized',...
'Position', [0.35 0.80 breite hoehe],...
'string', num2str(xa),...
'CallBack', {@call, ['xa']});

hc.xs=uicontrol('style', 'edit', 'units', 'normalized',...
'Position', [0.35 0.75 breite hoehe],...
'string', num2str(xs),...
'CallBack', {@call, ['xs']});

hc.xe=uicontrol('style', 'edit', 'units', 'normalized',...
'Position', [0.35 0.7 breite hoehe],...
'string', num2str(xe),...
'CallBack', {@call, ['xe']});

ht.xa=uicontrol('style', 'text', 'units','normalized',...
'HorizontalAlignment', 'Left',...
'BackgroundColor', [0.8 0.8 0.8],...
'Position', [0.45 0.80 1.5*breite hoehe],...
'string', 'xanfang');
ht.xs=uicontrol('style', 'text', 'units','normalized',...
'HorizontalAlignment', 'Left',...
'BackgroundColor', [0.8 0.8 0.8],...
'Position', [0.45 0.75 1.5*breite hoehe],...
'string', 'xschritt');


ht.xe=uicontrol('style', 'text', 'units','normalized',...
'HorizontalAlignment', 'Left',...
'BackgroundColor', [0.8 0.8 0.8],...
'Position', [0.45 0.7 1.5*breite hoehe],...
'string', 'xende');


hc.ya=uicontrol('style', 'edit', 'units', 'normalized',...
'Position', [0.35 0.65 breite hoehe],...
'string', num2str(ya),...
'CallBack', {@call, ['ya']});

hc.ys=uicontrol('style', 'edit', 'units', 'normalized',...
'Position', [0.35 0.60 breite hoehe],...
'string', num2str(ys),...
'CallBack', {@call, ['ys']});

hc.ye=uicontrol('style', 'edit', 'units', 'normalized',...
'Position', [0.35 0.55 breite hoehe],...
'string', num2str(ye),...
'CallBack', {@call, ['ye']});

ht.ya=uicontrol('style', 'text', 'units','normalized',...
'HorizontalAlignment', 'Left',...
'BackgroundColor', [0.8 0.8 0.8],...
'Position', [0.45 0.65 1.5*breite hoehe],...
'string', 'yanfang');
ht.ys=uicontrol('style', 'text', 'units','normalized',...
'HorizontalAlignment', 'Left',...
'BackgroundColor', [0.8 0.8 0.8],...
'Position', [0.45 0.60 1.5*breite hoehe],...
'string', 'yschritt');


ht.ye=uicontrol('style', 'text', 'units','normalized',...
'HorizontalAlignment', 'Left',...
'BackgroundColor', [0.8 0.8 0.8],...
'Position', [0.45 0.55 1.5*breite hoehe],...
'string', 'yende');




hc.zeitanfang=uicontrol('style', 'edit', 'units', 'normalized',...
'Position', [0.55 0.80 breite hoehe],...
'string', num2str(ta),...
'CallBack', {@call, ['ta']});

ht.zeitanfang=uicontrol('style', 'text', 'units','normalized',...
'HorizontalAlignment', 'Left',...
'BackgroundColor', [0.8 0.8 0.8],...
'Position', [0.63 0.80 1.5*breite hoehe],...
'string', 'zeit (A)');
hc.zeitschritt=uicontrol('style', 'edit', 'units', 'normalized',...
'Position', [0.55 0.75 breite hoehe],...
'string', num2str(ts),...
'CallBack', {@call, ['ts']});

ht.zeitschritt=uicontrol('style', 'text', 'units','normalized',...
'HorizontalAlignment', 'Left',...
'BackgroundColor', [0.8 0.8 0.8],...
'Position', [0.63 0.75 1.5*breite hoehe],...
'string', 'zeit (S)');
hc.zeitende=uicontrol('style', 'edit', 'units', 'normalized',...
'Position', [0.55 0.70 breite hoehe],...
'string', num2str(te),...
'CallBack', {@call, ['te']});

ht.zeitende=uicontrol('style', 'text', 'units','normalized',...
'HorizontalAlignment', 'Left',...
'BackgroundColor', [0.8 0.8 0.8],...
'Position', [0.63 0.70 1.5*breite hoehe],...
'string', 'zeit (E)');
%ht.zeit2=uicontrol('style', 'text', 'units','normalized',...
% 'HorizontalAlignment', 'Left',...
% 'BackgroundColor', [0.8 0.8 0.8],...
% 'Position', [0.43 0.65 2*breite hoehe],...
% 'string', 'Belichtungszeit');




%hc.laden=uicontrol('style', 'pushbutton', 'units', 'normalized',...
% 'Position', [0.6 0.8 2*breite hoehe],...
%'string', 'Bild Laden',...
%'BackgroundColor', [0 1 0],...
% 'CallBack', {@call, ['laden']});

hc.start=uicontrol('style', 'pushbutton', 'units', 'normalized',...
'Position', [0.85 0.13 breite hoehe],...
'string', 'start',...
'BackgroundColor', [1 0 0],...
'CallBack', {@call, ['start']});
hc.test=uicontrol('style', 'pushbutton', 'units', 'normalized',...
'Position', [0.85 0.17 breite hoehe],...
'string', 'test',...
'BackgroundColor', [1 0 0],...
'CallBack', {@call, ['test']});


hc.geraet1=uicontrol('units','normalized','position',[0.07, 0.8, 2.5*breite, hoehe],...
'style','popup','string',{'parametersweep','Belichtung'},...
'value',1,'callback',{@call, ['changetype']});
hc.geraet2 = uicontrol('units','normalized','position',[0.07, 0.7, 2.5*breite, hoehe],...
'style','popup','string',{''},'value',1,'callback',{@call, ['hc.graet2']});


end

mein call:
function call(hObject, eventdata, woundwas)
switch woundwas
case 'xa'

if evalin('base', 'xb<xa<xm')
if (evalin('base', 'start==1'))%Schloss offen?
assignin('base', 'neuerwert', get(hObject, 'string'));
evalin ('base', [woundwas '=str2num(neuerwert)']);
end

else
fprintf('Zahl liegt außerhalb der Grenzen \n')
end


case 'xs'
if (evalin('base', 'start==1'))%Schloss offen?
assignin('base', 'neuerwert', get(hObject, 'string'));
evalin ('base', [woundwas '=str2num(neuerwert)']);

end

case 'xe'
if (evalin('base', 'start==1'))%Schloss offen?
assignin('base', 'neuerwert', get(hObject, 'string'));
evalin ('base', [woundwas '=str2num(neuerwert)']);
end


case 'ya'
if (evalin('base', 'start==1'))%Schloss offen?
assignin('base', 'neuerwert', get(hObject, 'string'));
evalin ('base', [woundwas '=str2num(neuerwert)']);
end

case 'ys'
if (evalin('base', 'start==1'))%Schloss offen?
assignin('base', 'neuerwert', get(hObject, 'string'));
evalin ('base', [woundwas '=str2num(neuerwert)']);
end
case 'ye'
if (evalin('base', 'start==1'))%Schloss offen?
assignin('base', 'neuerwert', get(hObject, 'string'));
evalin ('base', [woundwas '=str2num(neuerwert)']);
end

case 'ta'
if (evalin('base', 'start==1'))%Schloss offen?
assignin('base', 'neuerwert', get(hObject, 'string'));
evalin ('base', [woundwas '=str2num(neuerwert)']);
end
case 'ts'
if (evalin('base', 'start==1'))%Schloss offen?
assignin('base', 'neuerwert', get(hObject, 'string'));
evalin ('base', [woundwas '=str2num(neuerwert)']);
end

case 'te'
if (evalin('base', 'start==1'))%Schloss offen?
assignin('base', 'neuerwert', get(hObject, 'string'));
evalin ('base', [woundwas '=str2num(neuerwert)']);
end

case 'start' %Pushbutton "START" gedrückt
if (evalin('base', 'start==1'))%Umschalten
assignin('base', 'start',0);
evalin('base', 'set(hc.start, ''BackgroundColor'', [1 0 0] )');
%assignin('base',hc.start.string, 'offen');
else
assignin('base', 'start',1);
evalin('base', 'set(hc.start, ''BackgroundColor'', [0 1 0] )');
%assignin('base',hc.start.string, 'geschlossen');
end
case 'test' %Pushbutton "START" gedrückt
if (evalin('base', 'test==1'))%Umschalten
assignin('base', 'test',0);
evalin('base', 'set(hc.test, ''BackgroundColor'', [1 0 0] )');
%assignin('base',hc.start.string, 'offen');
else
assignin('base', 'test',1);
evalin('base', 'set(hc.test, ''BackgroundColor'', [0 1 0] )');
%assignin('base',hc.start.string, 'geschlossen');
end


case 'changetype'
if (evalin('base','start==1'));
switch get(hObject,'value')
case 1
evalin('base','set(hc.geraet2, ''string'', {''standard'',''manuel''})');
case 2
evalin('base','set(hc.geraet2, ''string'', {''standard'',''manuel''})');
end
end


end

if ((evalin('base', 'start==1'))&&(evalin ('base',...
'get (hc.geraet1, ''value'')')==2)&&...
(evalin('base', 'get(hc.geraet2, ''value'')')==1));


evalin('base', 'xa=20;');
evalin('base', 'xs=20;');
evalin('base', 'xe=20;');
evalin('base', 'ya=20;');
evalin('base', 'ys=20;');
evalin('base', 'ye=20;');
evalin('base', 'ta=1000;');
evalin('base', 'ts=1000;');
evalin('base', 'te=2000;');
end

if ((evalin('base', 'start==1'))&&(evalin ('base',...
'get (hc.geraet1, ''value'')')==1)&&...
(evalin('base', 'get(hc.geraet2, ''value'')')==1));


evalin('base', 'xa=20;');
evalin('base', 'xs=20;');
evalin('base', 'xe=20;');
evalin('base', 'ya=20;');
evalin('base', 'ys=20;');
evalin('base', 'ye=20;');
evalin('base', 'ta=1000;');
evalin('base', 'ts=1000;');
evalin('base', 'te=2000;');
end


evalin('base', ['set(hc.xa, ''string'' , xa )']);
evalin('base', ['set(hc.xs, ''string'' , xs )']);
evalin('base', ['set(hc.xe, ''string'' , xe )']);
evalin('base', ['set(hc.ya, ''string'' , ya )']);
evalin('base', ['set(hc.ys, ''string'' , ys )']);
evalin('base', ['set(hc.ye, ''string'' , ye )']);
evalin('base', ['set(hc.zeitanfang, ''string'' , ta )']);
evalin('base', ['set(hc.zeitschritt, ''string'' , ts )']);
evalin('base', ['set(hc.zeitende, ''string'' , te )']);


end
mein Mfile:
clear all; close all; clc;


%initLED;
%time = [ta:ts:te];

time = 800;

?lta_x = 1.5;
?lta_y = 1.5;



pos_x = [xa:xs:xe]
pos_y = [ya:ys:ye];



shrlib = 'alpD41.dll';
hfile = 'alp.h';
%hfile = 'alpbasic.h';
libaliasalp = 'alp';



image_name = 'Justage.bmp';

image = int8(imread(image_name));



image = reshape(image',[],1);

%image = int8(ones(1, 1024*768/8)*0);


%image = int8(ones(1024*768*2,1)*128);

%image = [image ; image];


% #defines from alpbasic.h
alpid = 0;
%alpid = int64(alpid);
nDmdType = 0;
ALPB_DEV_SERIAL = 4;
ALPB_DEV_DMDTYPE = 5;
ALP_DEFAULT = 0;
nPictureTime = 15000000;

nSeqId = 1;


% only load dll if it wasn't loaded before
if(~libisloaded(libaliasalp))
[notfound,warnings]=loadlibrary (shrlib,hfile,'alias',libaliasalp);
end

% allôcate DLP device
[ret alpid] = calllib(libaliasalp,'AlpDevAlloc',ALP_DEFAULT,ALP_DEFAULT,alpid);

if (ret > 0)
disp('Error');
break;
end

%illum(0)

[ret nSeqId] = calllib(libaliasalp,'AlpSeqAlloc', alpid, 8, 1, nSeqId);

[ret] = calllib(libaliasalp,'AlpSeqPut',alpid, nSeqId, 0, 1, image/127 * 255);

%[ret] = calllib(libaliasalp,'AlpSeqControl', alpid, nSeqId, 1, ALP_DEFAULT);

%[ret] = calllib(libalias,'AlpSeqPut',alpid, nSeqId, 0, 2, image);

[ret] = calllib(libaliasalp,'AlpSeqTiming',alpid, nSeqId, ALP_DEFAULT, nPictureTime,ALP_DEFAULT, ALP_DEFAULT, ALP_DEFAULT);

[ret] = calllib(libaliasalp,'AlpProjStartCont',alpid, nSeqId);

%[ret nDmdType] = calllib(libalias,'AlpDevInquire', alpid, ALPB_DEV_DMDTYPE, nDmdType );
%
% pause(5);

%illum(4250);

%endLED;
%[ret] = calllib(libaliasalp,'AlpDevFree',alpid);
%
%%
%
initLED;

%%
initPiezo;



%%

movPiezo(30,10);


%%
%movPiezo(25,25);
%pause(1);

illum(1)

%%

pos_x = [0:-0.975:-4.875];
pos_y = [0:-1.385:-6.925];

pic_num = 1;

%illum(1)


%for pic_num = 1:16
for x_cnt = 1:4;
for y_cnt = 1:4;

movPiezo(30 - pos_x(x_cnt),10 + pos_y(y_cnt));
%movPiezo(26,26);

image_name = ['logo' num2str(pic_num) '.bmp'];
image = uint8(imread(image_name));
image = reshape(image',[],1);


[ret alpid] = calllib(libaliasalp,'AlpDevAlloc',ALP_DEFAULT,ALP_DEFAULT,alpid);
pause(0.5);

[ret nSeqId] = calllib(libaliasalp,'AlpSeqAlloc', alpid, 8, 1, nSeqId);
[ret] = calllib(libaliasalp,'AlpSeqPut',alpid, nSeqId, 0, 1, image);
%[ret] = calllib(libaliasalp,'AlpSeqPut',alpid, nSeqId, 0, 1, image);
%[ret] = calllib(libaliasalp,'AlpSeqTiming',alpid, nSeqId, ALP_DEFAULT, nPictureTime,ALP_DEFAULT, ALP_DEFAULT, ALP_DEFAULT);
%[ret] = calllib(libaliasalp,'AlpSeqTiming',alpid, nSeqId, ALP_DEFAULT, ALP_DEFAULT,ALP_DEFAULT, ALP_DEFAULT, ALP_DEFAULT);
[ret] = calllib(libaliasalp,'AlpSeqTiming',alpid, nSeqId, ALP_DEFAULT, nPictureTime, ALP_DEFAULT, ALP_DEFAULT, ALP_DEFAULT);
%pause(1);
[ret] = calllib(libaliasalp,'AlpProjStartCont',alpid, nSeqId);



%pause(1);
pause(2);

%illum(4250);
time = 1000;

illum(time);
pause(time/1000 + 0.1);
[ret] = calllib(libaliasalp,'AlpDevHalt',alpid);
[ret] = calllib(libaliasalp,'AlpDevFree',alpid);
pause(0.5)
pic_num = pic_num + 1;
end
end

%%
movPiezo(25,25);
pause(1);
endPiezo;
endLED;



%%
[ret] = calllib(libaliasalp,'AlpDevFree',alpid);

unloadlibrary(libaliasalp);
Neue Frage »
Antworten »



Verwandte Themen