Dear All, I am new to MATLAb GUI and want to create one. My program should work in the following sequence. 1) Select option of polarity from a pop-up menu (total two options are available) 2) load file according to polarity selected 3) execute part

조회 수: 1 (최근 30일)
My Matlab script is as follows (which works perfectly but i have to change it to GUI for user readiness)
R_pp=[]; Vf_pp=[];
for i=1:Nmeas_pp
Vf_pp=vertcat(Vf_pp,x_pp(i),y_pp(i));
k=B_pp(i)/(2*rigidity); % m^(-1)
M11_pp=cos(k*l)^2*(cos(k*l)^2 - D*k*cos(k*l)*sin(k*l)) + k*sin(k*l)^2*(sin(k*l)^2/k + D*cos(k*l)*sin(k*l)) - cos(k*l)*sin(k*l)*(cos(k*l)*sin(k*l) - D*k*sin(k*l)^2) - k*cos(k*l)*sin(k*l)*(D*cos(k*l)^2 + (cos(k*l)*sin(k*l))/k);
M12_pp=cos(k*l)^2*(D*cos(k*l)^2 + (cos(k*l)*sin(k*l))/k) - cos(k*l)*sin(k*l)*(sin(k*l)^2/k + D*cos(k*l)*sin(k*l)) - (sin(k*l)^2*(cos(k*l)*sin(k*l) - D*k*sin(k*l)^2))/k + (cos(k*l)*sin(k*l)*(cos(k*l)^2 - D*k*cos(k*l)*sin(k*l)))/k;
M13_pp=cos(k*l)^2*(cos(k*l)*sin(k*l) - D*k*sin(k*l)^2) - k*sin(k*l)^2*(D*cos(k*l)^2 + (cos(k*l)*sin(k*l))/k) + cos(k*l)*sin(k*l)*(cos(k*l)^2 - D*k*cos(k*l)*sin(k*l)) - k*cos(k*l)*sin(k*l)*(sin(k*l)^2/k + D*cos(k*l)*sin(k*l));
M14_pp=cos(k*l)^2*(sin(k*l)^2/k + D*cos(k*l)*sin(k*l)) + cos(k*l)*sin(k*l)*(D*cos(k*l)^2 + (cos(k*l)*sin(k*l))/k) + (sin(k*l)^2*(cos(k*l)^2 - D*k*cos(k*l)*sin(k*l)))/k + (cos(k*l)*sin(k*l)*(cos(k*l)*sin(k*l) - D*k*sin(k*l)^2))/k;
M31_pp=k*sin(k*l)^2*(D*cos(k*l)^2 + (cos(k*l)*sin(k*l))/k) - cos(k*l)^2*(cos(k*l)*sin(k*l) - D*k*sin(k*l)^2) - cos(k*l)*sin(k*l)*(cos(k*l)^2 - D*k*cos(k*l)*sin(k*l)) + k*cos(k*l)*sin(k*l)*(sin(k*l)^2/k + D*cos(k*l)*sin(k*l));
M32_pp= -cos(k*l)^2*(sin(k*l)^2/k + D*cos(k*l)*sin(k*l)) - cos(k*l)*sin(k*l)*(D*cos(k*l)^2 + (cos(k*l)*sin(k*l))/k) - (sin(k*l)^2*(cos(k*l)^2 - D*k*cos(k*l)*sin(k*l)))/k - (cos(k*l)*sin(k*l)*(cos(k*l)*sin(k*l) - D*k*sin(k*l)^2))/k;
M33_pp=cos(k*l)^2*(cos(k*l)^2 - D*k*cos(k*l)*sin(k*l)) + k*sin(k*l)^2*(sin(k*l)^2/k + D*cos(k*l)*sin(k*l)) - cos(k*l)*sin(k*l)*(cos(k*l)*sin(k*l) - D*k*sin(k*l)^2) - k*cos(k*l)*sin(k*l)*(D*cos(k*l)^2 + (cos(k*l)*sin(k*l))/k);
M34_pp=cos(k*l)^2*(D*cos(k*l)^2 + (cos(k*l)*sin(k*l))/k) - cos(k*l)*sin(k*l)*(sin(k*l)^2/k + D*cos(k*l)*sin(k*l)) - (sin(k*l)^2*(cos(k*l)*sin(k*l) - D*k*sin(k*l)^2))/k + (cos(k*l)*sin(k*l)*(cos(k*l)^2 - D*k*cos(k*l)*sin(k*l)))/k;
Rlinex_pp= [M11_pp, M12_pp, M13_pp, M14_pp];
Rliney_pp= [M31_pp, M32_pp, M33_pp, M34_pp];
R_pp=vertcat(R_pp,Rlinex_pp,Rliney_pp);
end
R_mp=[];
Vf_mp=[];
for i=1:Nmeas_mp
Vf_mp=vertcat(Vf_mp,x_mp(i),y_mp(i));
k=B_mp(i)/(2*rigidity); % m^(-1)
M11_mp=cos(k*l)^2*(cos(k*l)^2 - D*k*cos(k*l)*sin(k*l)) - k*sin(k*l)^2*(sin(k*l)^2/k + D*cos(k*l)*sin(k*l)) + cos(k*l)*sin(k*l)*(cos(k*l)*sin(k*l) - D*k*sin(k*l)^2) - k*cos(k*l)*sin(k*l)*(D*cos(k*l)^2 + (cos(k*l)*sin(k*l))/k);
M12_mp=cos(k*l)^2*(D*cos(k*l)^2 + (cos(k*l)*sin(k*l))/k) + cos(k*l)*sin(k*l)*(sin(k*l)^2/k + D*cos(k*l)*sin(k*l)) + (sin(k*l)^2*(cos(k*l)*sin(k*l) - D*k*sin(k*l)^2))/k + (cos(k*l)*sin(k*l)*(cos(k*l)^2 - D*k*cos(k*l)*sin(k*l)))/k;
M13_mp=cos(k*l)^2*(cos(k*l)*sin(k*l) - D*k*sin(k*l)^2) + k*sin(k*l)^2*(D*cos(k*l)^2 + (cos(k*l)*sin(k*l))/k) - cos(k*l)*sin(k*l)*(cos(k*l)^2 - D*k*cos(k*l)*sin(k*l)) - k*cos(k*l)*sin(k*l)*(sin(k*l)^2/k + D*cos(k*l)*sin(k*l));
M14_mp=cos(k*l)^2*(sin(k*l)^2/k + D*cos(k*l)*sin(k*l)) - cos(k*l)*sin(k*l)*(D*cos(k*l)^2 + (cos(k*l)*sin(k*l))/k) - (sin(k*l)^2*(cos(k*l)^2 - D*k*cos(k*l)*sin(k*l)))/k + (cos(k*l)*sin(k*l)*(cos(k*l)*sin(k*l) - D*k*sin(k*l)^2))/k;
M31_mp=cos(k*l)*sin(k*l)*(cos(k*l)^2 - D*k*cos(k*l)*sin(k*l)) - k*sin(k*l)^2*(D*cos(k*l)^2 + (cos(k*l)*sin(k*l))/k) - cos(k*l)^2*(cos(k*l)*sin(k*l) - D*k*sin(k*l)^2) + k*cos(k*l)*sin(k*l)*(sin(k*l)^2/k + D*cos(k*l)*sin(k*l));
M32_mp=cos(k*l)*sin(k*l)*(D*cos(k*l)^2 + (cos(k*l)*sin(k*l))/k) - cos(k*l)^2*(sin(k*l)^2/k + D*cos(k*l)*sin(k*l)) + (sin(k*l)^2*(cos(k*l)^2 - D*k*cos(k*l)*sin(k*l)))/k - (cos(k*l)*sin(k*l)*(cos(k*l)*sin(k*l) - D*k*sin(k*l)^2))/k;
M33_mp=cos(k*l)^2*(cos(k*l)^2 - D*k*cos(k*l)*sin(k*l)) - k*sin(k*l)^2*(sin(k*l)^2/k + D*cos(k*l)*sin(k*l)) + cos(k*l)*sin(k*l)*(cos(k*l)*sin(k*l) - D*k*sin(k*l)^2) - k*cos(k*l)*sin(k*l)*(D*cos(k*l)^2 + (cos(k*l)*sin(k*l))/k);
M34_mp=cos(k*l)^2*(D*cos(k*l)^2 + (cos(k*l)*sin(k*l))/k) + cos(k*l)*sin(k*l)*(sin(k*l)^2/k + D*cos(k*l)*sin(k*l)) + (sin(k*l)^2*(cos(k*l)*sin(k*l) - D*k*sin(k*l)^2))/k + (cos(k*l)*sin(k*l)*(cos(k*l)^2 - D*k*cos(k*l)*sin(k*l)))/k;
Rlinex_mp= [M11_mp, M12_mp, M13_mp, M14_mp];
Rliney_mp= [M31_mp, M32_mp, M33_mp, M34_mp];
R_mp=vertcat(R_mp,Rlinex_mp,Rliney_mp);
end
lsqr(R_pp, Vf_pp)
lsqr(R_mp, Vf_mp)

채택된 답변

Adam Danz
Adam Danz 2018년 8월 14일
Hello Sumera,
If you've already got the code, the hard part is done :) To start with the GUI, I'll recommend using guide().
From matlab command window, run
guide
which will open a window. Select the "Create new GUI' tab, the select "Blank GUI", then "OK" button. This will open an untitled figure where you can drag and drop GUI components and design your GUI. Hover your mouse over the GUI components on the left to see what they are. You'll see pop-up Menu and others. Once you drag them to the figure space, right click on the component and open "property inspector". Here you'll have all of the options available for that component. You can search for answers on google or within this forum to learn about those options.
When you save the figure it will produce code with callback functions etc. If you get stuck, feel free to ask follow-up questions.
  댓글 수: 6
Adam Danz
Adam Danz 2018년 8월 16일
help sprintf
sptrinf() formats numbers.
pi = 3.141592653.... but I only want to display the first 2 decimal places. Run that line of code to see the result.
The '\n' part of the 2nd example makes a new row of text. Run that line to see the result.
Adam Danz
Adam Danz 2018년 8월 16일
Question copied here: Hi, but how would i link the result of my code in .m file (lsqr(R_pp, Vf_pp) in my original code) to the GUI?
You have to use the handle to the object. In my code above, 'edit1' is the handle to the object. If you're using GUIDE, use the 'handles' structure.
handles.edit1.String = 'blah';

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Sumera Yamin
Sumera Yamin 2018년 8월 16일
Thank you very much for the clarification.

카테고리

Help CenterFile Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by