matlab-guide

Matlab- Improve code in image cropping black border

老子叫甜甜 提交于 2019-11-26 21:56:41
问题 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)

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

痴心易碎 提交于 2019-11-26 21:17:40
问题 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. 回答1: Even though the callback of the slider isn't being called as

Stop A GUI in a middle of process in MATLAB

耗尽温柔 提交于 2019-11-26 20:29:47
问题 I'm designing a GUI using GUIDE in MATLAB R2014b. My program has a long loop (takes 2~5h to process). I want have a button in my GUI that the user stop the process every time he/she want (The GUI is updating graphs and texts continuously based on result of loops). Something like pressing Control+C not after ending a loop. How can I implement this? PS. I don't want MATLAB remove my workspace. The user can continue the process with previous loaded data and workspace by changing some options in

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

删除回忆录丶 提交于 2019-11-26 17:57:14
问题 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

How should I update the data of a plot in Matlab?

送分小仙女□ 提交于 2019-11-26 15:19:49
Suppose that I want to update a plot with a new data. What method should I choose? Set the XDataSource property to some name, update the variable, and call refreshdata Erase the original plot , and call plot command again. Use Set('Xdata',...') Andrey Rubshtein Short answer : always use Set('Xdata',...') . Example code: function PlotUpdate() x = 0:.1:8; y = sin(x); h = plot(x,y); y = sin(x.^3); set(h,'XData',x,'YData',y); end Long answer: There are three relevant measures by which one should choose the best method. Code clarity - How easy it is for someone to read your code? Runtime - How

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

纵饮孤独 提交于 2019-11-26 12:29: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 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? 回答1: The first place you need to go is Matlab Help on Creating Graphical User Interfaces . Then, you can

How should I update the data of a plot in Matlab?

怎甘沉沦 提交于 2019-11-26 04:19:53
问题 Suppose that I want to update a plot with a new data. What method should I choose? Set the XDataSource property to some name, update the variable, and call refreshdata Erase the original plot , and call plot command again. Use Set(\'Xdata\',...\') 回答1: Short answer : always use Set('Xdata',...') . Example code: function PlotUpdate() x = 0:.1:8; y = sin(x); h = plot(x,y); y = sin(x.^3); set(h,'XData',x,'YData',y); end Long answer: There are three relevant measures by which one should choose

How to put these images together?

安稳与你 提交于 2019-11-25 21:59:07
问题 I have 200 time points. For each time point, there is an image, the size of which is 40*40 double , corresponds to this time point. For example, image 1 corresponds to time point 1 ; image k corresponds to time point k ( k = 1,2,...,200 ). The time points are T = 1:200 , with the images named as Image_T , thus Image_1 , Image_2 etc. I want to put all these 200 images together. The final size is 40*40*200 double. The final image looks like fMRI image ( fmri_szX = 40 , fmri_szY = 40 and fmri