matlab-guide

Global (shared) variables in Matlab GUI code behind. Is there better way to do it then using handles structure?

别来无恙 提交于 2019-11-29 14:54:47
I have spent some time lately creating complex Matlab GUI tool. I'm using GUIDE GUI builder. I dislike the way Matlab manages global variables in code behind (the .m file with functions). If I want to share data between function calls I have to store them in handles structure that is given as a parameter to every function call. I consider it to be bug prone as I have to mind storing and updating handles all the time. It is rather unnatural for me to handle global variables this way. Using appdata is even worse. Is it possible to use class as a code behind for GUI? All the callbacks would be

Make a pixel transparent in Matlab

北慕城南 提交于 2019-11-29 14:13:34
问题 I have imported an image in matlab and before I display it how would I make the background of the image transparent? For example I have a red ball on a white background, how would i make the white pixels of the image tranparent so that only the red ball is visible and the white pixels are transparent? 回答1: You need to make sure the image is saved in the 'png' format. Then you can use the 'Alpha' parameter of a png file, which is a matrix that specifies the transparency of each pixel

Running a GUI requires opening the .fig file in GUIDE

旧巷老猫 提交于 2019-11-29 11:56:25
I am trying to run a MATLAB GUI I have created. If I open the .fig file using GUIDE and press the run button there, it runs perfectly. However, when I double-click the .fig file in the 'Current Folder' section of MATLAB, it seems to be unable to find the handles variable. This causes it to give an error whenever handles is used. Why does this happen? Is there a fix/workaround? I'm using MATLAB R2011, but I've tried it on R2012 as well. The code runs fine, and displays the GUI fine, but the moment it encounters the handles variable, it gives the following error: Attempt to reference field of

Is the MATLAB gui creator GUIDE as awful as I think? Is there an alternative? [closed]

痴心易碎 提交于 2019-11-28 17:38:46
问题 I've been trying to put together a gui in MATLAB and have had great difficulty. Here is a little background about my program: I want to create a wizard to step users through an image analysis process. The wizard will cue users for their input and then perform an image processing action once a button labeled "Next" has been pressed, and so on. From reading the MATLAB help I believe there are two approaches to gui creation: 1. write a gui with lines of code. 2. use GUIDE. I figured GUIDE would

MATLAB: Duplicate each element of a vector? [closed]

梦想的初衷 提交于 2019-11-28 01:44:08
I'm new to MATLAB and this website as well. I tried searching for this question, but to no avail (so I apologize if this ends up being a questions which has already been asked here before). In class, we were assigned a problem with the following description: "For an n-dimensional vector X, the function should return another 2n-dimension where each element is repeated twice. For example: if a=[2 3 4 5], after using the function, a=[2 2 3 3 4 4 5 5];" It should work with a vector of ANY random size. Your help is really appreciated! Thanks use kron : K = kron(X,Y) returns the Kronecker tensor

Matlab- Improve code in image cropping black border

余生颓废 提交于 2019-11-28 01:37:35
I have this code that crop the black borders in my picture. I don't know why the border still exists. I1=im2double(imread('dart.jpg')); sizeI = size(I1); zeros = floor((sizeI(2) - min(sum(any(I1))))/2); I2 = I1(:, zeros : sizeI(2)-zeros, :); nonZero = sum(any(I1,2)); sizeI2 = size(I2); zerosRows = floor((sizeI(1) - min(sum(any(I2, 2))))/2); I3 = I2(zerosRows : sizeI2(1)-zerosRows, :, :); subplot(1,3,1), imshow(I1);title('Figure 1'); subplot(1,3,2), imshow(I2);title('Figure 2'); subplot(1,3,3), imshow(I3);title('Figure 3'); How can I change this code ? This code works for me, assuming that your

In MATLAB, how can you have a callback execute while a slider is being dragged?

末鹿安然 提交于 2019-11-27 23:03:23
I have created a MATLAB GUI using GUIDE. I have a slider with a callback function. I have noticed that this callback, which is supposed to execute 'on slider movement', in fact only runs once the slider has been moved and the mouse released. Is there a way to get a script to run as the slider is being dragged, for live updating of a plot? There would I presume need to be something to stop the script being run too many times. Even though the callback of the slider isn't being called as the mouse is moved, the 'Value' property of the slider uicontrol is being updated. Therefore, you could create

What's the “right” way to organize GUI code?

倖福魔咒の 提交于 2019-11-27 10:32:21
I'm working on a fairly sophisticated GUI program to be deployed with MATLAB Compiler. (There are good reasons MATLAB is being used to build this GUI, that is not the point of this question. I realize GUI-building is not a strong suit for this language.) There are quite a few ways to share data between functions in a GUI, or even pass data between GUIs within an application: setappdata/getappdata/_____appdata - associate arbitrary data to a handle guidata - typically used with GUIDE; "store[s] or retrieve[s] GUI data" to a structure of handles Apply a set/get operation to the UserData property

How can I program a GUI in MATLAB? [closed]

China☆狼群 提交于 2019-11-27 01:54:21
I need to create a GUI in MATLAB for my project. I looked everywhere for examples of how to program a GUI but I couldn't find a lot. What are some good sites or techniques for GUI programming in MATLAB? The first place you need to go is Matlab Help on Creating Graphical User Interfaces . Then, you can watch this tutorial video or this one This tutorial is also good. Here are all the videos that I have made about making MATLAB GUIs http://blogs.mathworks.com/videos/category/gui-or-guide/ I recently had to program a simple GUI that controls some plots. I don't know exactly what your task is, but

MATLAB: Duplicate each element of a vector? [closed]

我是研究僧i 提交于 2019-11-26 23:34:30
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I'm new to MATLAB and this website as well. I tried searching for this question, but to no avail (so I apologize if this ends up being a questions which has already been asked here before). In class, we were assigned a problem with the following description: "For an n-dimensional vector X, the function should