matlab-guide

How to merge two files into one text file?

不想你离开。 提交于 2020-01-11 14:00:21
问题 I am trying to merge two text output file into one text file . file 1: fin=fopen('d://box1.txt','wt'); fprintf(fin,' Hello \n'); file 2: fin=fopen('d://box2.txt','wt'); fprintf(fin,'welcome \n'); Any thoughts? 回答1: I don't think there is a matlab way of doing it easily. But you can use system commands: Windows: system(type a.txt b.txt >ab.txt) Linux: system(cat a.txt b.txt >ab.txt) Dont forget to put the path in the files if they are not in your current directory! This works: fin=fopen('D:

updating data within same GUI in MATLAB

こ雲淡風輕ζ 提交于 2020-01-06 20:23:52
问题 I've created one image editor window in MATLAB, which includes various operations including brightness, contrast, crop, rotate etc.., In this GUI, each operations has its own function call backs. My problem is with linking one function with another. if i crop image, then if i change brightness my current code changes brightness of original image rather than cropped image. similarly at first i if change brightness and then if i crop, my code will crop original image rather than brightened

Randomly number selector from a given list of numbers [duplicate]

倾然丶 夕夏残阳落幕 提交于 2020-01-06 07:56:08
问题 This question already has answers here : Generate numbers randomly from a set? (2 answers) Closed 10 months ago . I have given list of numbers, x=[x1, x2, x3, x4, x5, x6]; non_zero=find(x); I want Matlab to randomly select anyone among elements of 'non_zero' at a time. I searched online but there is no such function available to provide my required results. 回答1: You could use the function randi to randomly select an integer from the set of valid indices. x=[x1, x2, x3, x4, x5, x6]; non_zero

Conditional coloring of histogram graph in MATLAB

笑着哭i 提交于 2020-01-06 01:29:25
问题 I have a histogram that I want conditional coloring in it with this rule : Values that are upper than 50 have red bars and values lower than 50 have blue bars. Suppose that we have this input matrix: X = [32 64 32 12 56 76 65 44 89 87 78 56 96 90 86 95 100 65]; I want default bins of MATLAB and applying this coloring on X-axes (bins). I'm using GUIDE to design my GUI and this histogram is an axes in my GUI. This is our normal graph. Bars with upper values than 50 should be red and bars with

Structure of handles of GUIs MATLAB

橙三吉。 提交于 2020-01-05 03:46:28
问题 I have three GUIs in MATLAB. The tag of each of them is 'P0' , 'P1' and 'P2' . I would like to put the handles of all three GUIs in a structure and be able to get to this structure from any of three GUIs and update the values in it. What is the best way to accomplish this? 回答1: You have a couple of options on how to do this. One way would be to use the root graphics object along with setappdata and getappdata to store and retrieve values. fig0 = findall(0, 'tag', 'P0'); fig1 = findall(0, 'tag

How to create a GUI to play, pause, fast forward and rewind video in MATLAB?

不羁岁月 提交于 2020-01-04 04:37:13
问题 I am a newbie to MATLAB. I am trying to create a GUI to play, pause, fast forward and rewind an avi video frame by frame. At the moment I can play and pause the video, via a toggle button, but when I press play again the video plays from frame zero. I realise I need to store the frame number to be used the next time I press play but I don't know how to do this. Any help would be much appreciated. I realise there is an implay option in MATLAB but I have some other code to implement which I

Creating movie by sequence of plots in matlab

六眼飞鱼酱① 提交于 2020-01-03 05:47:08
问题 I'm asking this question in the following of the question question and answer After running the answer code, you can see a movie by sequences of plots. Is there a way to save the sequence of plots as movie? Any answer is highly appreciated. 回答1: You can create a video of a plot by using the VideoWriter object in the following steps: 1) Create and open the video object (also specifying the name of the video) vidObj = VideoWriter('SIN_X_COS_X.avi'); 2) in the plotting loop, get the current

parse text file in MATLAB [duplicate]

£可爱£侵袭症+ 提交于 2020-01-02 07:27:14
问题 This question already has an answer here : Parse file in MatLab (1 answer) Closed 6 years ago . How can I parse file in MATLAB? The data in the text has this format: p 15.01245 20.478 12.589 58.256 n 16.589 87.268 52.367 46.256 2.589 58.02 I want to store each data in separate array ( i.e ; store data under letter p in array 1, and data under letter n in array 2). any help? 回答1: Here is another solution: fstring = fileread('test.txt'); % read the file as one string fblocks = regexp(fstring,'

Scaleable, draggable box on plots that can select data

↘锁芯ラ 提交于 2020-01-01 09:24:36
问题 Here's the setup: I've got a graphical plot of data, and I'm trying to find if it's feasible to try to put a box on the figure that can be moved and changed in width and return some values like percentage of and area under the curve. It looks something like this: Any suggestions on where to start? My feeling was that it might be doable using a more GUI'd interface versus a standard plot. 回答1: I would start with imrect . It is draggable, and you can add callbacks to it. (Taken directly from

duplicate matlab command window to gui

☆樱花仙子☆ 提交于 2019-12-25 09:17:49
问题 I am asking this question in reference to this post as I wasn't able to comment to the original post. I used the code given in that post from @Hoki and mixed in my gui it is working fine. But sometimes i am getting following error Error using test_gui>scroll_to_bottom (line 176) Java exception occurred: java.lang.IllegalArgumentException: bad position: 13319 at javax.swing.text.JTextComponent.setCaretPosition(Unknown Source) Error in test_gui>commandWindowMirror (line 170) scroll_to_bottom(h