Labview and Matlab for PT

Just a place to discuss with Matlab and Labview

ad

It takes me 3 years to figure out how to do DAQ in labview!!!!!

Hahaha!!! The title of this article is not real. Not until someone tell me the concept of shift register did I write labview since I began writing matlab. Today, I spent two hours to know how to do DAQ in labview which I didn't accomplish 3 years ago. The main reason possibly is that labview is my first programming language and I know nothing about programming, so it was difficult for me to do DAQ at that time.

Here is my simple code:



How to run matlab 7.1 on windows 7??

Recently, I have upgraded almost my computers to windows 7 except the computer in my lab. Yesterday, I installed matlab 7.1 on my desktop and found out some errors when running the program, even using the comparable mode provided by windows 7. So I find the solution on the internet and here is the solution.

The original article is from this: How To Run Matlab 7.1 On Windows 7



Instructions

  1. Right Click On Desktop, choose Personalize
  2. Got to Basic and High Contrast Themes tab, and click Window Classic
  3. Now, Run matlab
  4. Finish



So, if you want to use matlab 7.1 on windows 7, you need to accept the ugly theme when running matlab program. It's also a little bit inconvenient because you have to switch the theme when running Matlab.

ginput -- A Useful and Convenient Function


Yesterday night, one of junior classmates told me that he found a useful function called "ginput" which can make the thing getting mouse position easier than using "get(gca......)". It's very convenient when designing some program such as calculating angle in coordinate plane. So, here is a very simple example about how to calculate the angle in a certain image.

global flag h_im h_1
filename='D:\07020203_mpg2-0000281.jpg';
im=imread(filename);
h_im=image(im);
while 1
    cal_cord_ang;
end

function cal_cord_ang
global flag h_im h_1
cla(h_im)
[x,y] = ginput(1);
a=[x,y];
x0=a(1,1);
y0=a(1,2);
hold on
h_1=plot(x0,y0,'color','r','marker','+');
[x,y] = ginput(1);
b=[x,y];
x1=b(1,1);
y1=b(1,2);
h_1=plot([x0 x1],[y0 y1],'color','r','marker','+');
[x,y] = ginput(1);
c=[x,y];
x2=c(1,1);
y2=c(1,2);
h_1=plot([x0 x1 x2],[y0 y1 y2],'color','r','marker','+');

% calculate angle by using this formula --> A dot B = ABcos
A=a-b;
B=c-b;
angle=acosd(dot(A,B)/(norm(A)*norm(B)));
x_t=mean([x0 x2]);
y_t=mean([y0 y2]);
text(x_t,y_t,num2str(angle),'color','r')
ginput(1)
cla(h_im)

However, I almost forget the concept of vector, even the product of two vectors. You can review the concept in this url: http://www.euclideanspace.com/maths/algebra/vectors/angleBetween/index.htm.

Try it, it's very funny!!!


[Transcripttion] 35 Complete GUI Examples

This article, 35 Complete GUI Examples, gives examples about GUI that I found today. It contains several questions that many people usually ask and also attaches the example codes. It is very useful reference when designing a GUI program.

Here is the description of this article:

The questions/files are written in approximate order of complexity, so intermediate users may want to skip the first several files. 
The questions answered include:

1. How do I manipulate the strings in a uicontrol? 
2. How do make a uicontrol invisible/visible?
 
3. How do I make a multi-line editbox?
 
4. How can I let the user of my GUI know his actions are futile (or producing no results)?
 
5. How can I tell which uicontrol is selected?
 
6. How can I tell how many times a uicontrol has been activated?
 
7. How do I tell which button in a buttongroup is selected?
 
8. How do I let the user know a process is running in the background?
 
9. How do I control the mouse pointer with a GUI?
 
10. How can I access the value (current position) of a slider?
 
11. How can I use different colored strings in a listbox?
 
12. What is the difference between 'listboxtop' and 'value' in a listbox?
 
13. How can I make text that can be copied but not changed?
 
14. How do I allow the user of my GUI to set the range of a slider?
 
15. How do I use the buttondownfcn on an axes object?
 
16. How do I make a callback talk to another callback?
 
17. How can I get the string from a popup or listbox?
 
18. How can I set the string in a popup or listbox?
 
19. How can I add to the string in a popup or listbox?
 
20. How do I tell which figure was current before my callback executed?
 
21. How do I get data from another GUI?
 
22. How do I make a GUI to open image files only?
 
23. How can I make popup choices mutually exclusive?
 
24. How can I show the current pointer location in axes coordinates?
 
25. How can I use uicontextmenus?
 
26. How do I make my GUI control an axes in another figure?
 
27. What are callback strings?
 
28. How can I make it so that when one of the figures closes, they all close?
 
29. How do I make several uicontrols interact in a more complicated GUI?
 
30. How do I get data from a GUI to the base workspace?
 
31. How do I make toggle buttons act like tabbed-panels?
 
32. How can I make a password editbox that has the ***** symbols?
 
33. How can I use nested function as callbacks?
 
34. How can I use uiwait in a GUI?
 
35. How do I use JAVA in my GUI?
 
36. How do I force the figure to maintain focus between uicontrol activations?
 
37. How do I save an axes as an image?
 
38. How can I make a simple drawing program?
 
39. How can I save the state of a system of GUIs to use later?

I am open to hearing any suggestion as to other questions which could be covered in the collection. Such suggestions need not be basic. Please read the pdf file prior to use. Also the contents.m file contains brief descriptions of each GUI.
Please email me if an error is found, either in the documentation or coding. Thanks.