matlab-guide

(Re-) Generating a draggable line in Matlab GUI

我们两清 提交于 2019-12-12 02:03:53
问题 I am currently building up a functionality in a Matlab GUI whereby the user can change the plot displayed on the screen (via a pop-up menu.... this isn't the issue FYI!) and move a vertical line across the plot with the mouse (the x-data is returned from the position of this line). I have no issues creating this mouse-interactive line when the GUI is first generated, but cannot "re-generate" the user-interactive line once the user selects a different dataset from the pop-up menu. I establish

MATLAB: Matrix containing values of another matrix at specific indices

六眼飞鱼酱① 提交于 2019-12-12 01:39:49
问题 I need help solving an indexing problem. The assigned problem states: Two matrices (x and y) give the coordinates to form matrix B from matrix A. Produce the matrix B which contains the values of A at the given coordinates in x and y. For instance: x = [1 1 1; 2 2 1] y = [1 2 1; 3 2 4] %This would read as (1,1),(1,2),(1,1),(2,3),(2,2),(1,4) % Given matrix: A = [6 7 8 9; 10 11 12 13]; %This would give us this answer for B (using the coordinate scheme above): B=[6 7 6; 12 11 9]; I'm guessing I

Create a “counter” on matlab from 0:limit-1. The length of counter is not determined in the program

你说的曾经没有我的故事 提交于 2019-12-11 20:39:53
问题 Q- Create a "counter" from 0:limit-1 (for example if you choose 3 it will display 0,1,2). The length of counter is not determined in the program and it should be determined when it is being run and the inputs can differ from each other this is the solution on python but i want to compute it on matlab. how do i do that? for i in range(3): print(3-i) for s in range(3,-1,-1) print s so the answer is : 3 2 1 3 2 1 0 回答1: As Dan hinted you in the comments above, the colon operator of Matlab

Calling GUI function from different GUI in Matlab

烈酒焚心 提交于 2019-12-11 17:03:45
问题 I have two GUI files, which are as follows: gui1.m function varargout = gui1(varargin) gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @gui1_OpeningFcn, ... 'gui_OutputFcn', @gui1_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State

Too many input arguments to uicontrol callback

人走茶凉 提交于 2019-12-11 15:03:36
问题 I am trying to write a scroll bar that changes the x-range of many subplots at the same time. kids = get(gcf,'Children'); h=uicontrol('style','slider',... 'units','normalized','position',Newpos,... 'callback',{@slide_axes,kids},'min',0,'max',xmax-chunkDuration); Update_axes is defined in the same file: function slide_axes(h) set(h,'xlim',get(gcbo,'value')+[0 20000]); end However, I get the error: ??? Error using plot_scroll>slide_axes Too many input arguments. ??? Error while evaluating

Creating multi-line 'String' in a static text of a GUI

≡放荡痞女 提交于 2019-12-11 04:56:59
问题 I have a static text in GUI and need to write something like: y1 = A[1] y2 = A[2] y3 = A[3] etc. (there is a certain limit, right now this is not important). Where y1, y2, y3 are strings , and A[1], A[2], A[3] are numbers in a matrix A . I'm just not sure how to enter a new line in that static text, meaning I'm not sure how to go from y1 to y2 . I know there are a lot of answers to this question on the Internet but I can't find one that suits my needs for some reason. How can I do that? Thank

Populating a Matlab GUI Listbox from Database Values

与世无争的帅哥 提交于 2019-12-11 04:55:12
问题 I am relatively new to GUI's in Matlab, and I have created a simple GUI using GUIDE. I want to connect to a database (already defined and working!) and populate a listbox with the values from the database so the user can choose which to use (in this case they are chemical compounds). I haven't been able to find a good tutorial or clues on how to populate the listbox in this way. So far, I have: function load_listbox(hObject,handles) conn = database('antoine_db','',''); setdbprefs(

MATLAB uitable row generation from user input

穿精又带淫゛_ 提交于 2019-12-11 01:46:51
问题 I've got a GUI in MATLAB which uses uitables for input. There are a fixed number columns, and each column has a very specific format which I have stored as a cell array, like so: columnformat = {'text', 'numeric', {@doSomething, inputArg1}, {'Option1' 'Option2'}}; The number of rows is theoretically unlimited; the user could provide as many they like. The back-end is capable of handling arbitrarily many row inputs. Right now, I'm building a large uitable initially, and just assuming the user

getappdata returning empty matrix in MATLAB

自闭症网瘾萝莉.ら 提交于 2019-12-10 23:48:05
问题 I have a piece of code in which I use setappdata and then later on I call the data using getappdata which returns an empty matirx even though it is not empty. A segment of my simplified code is below: function edit1_Callback(hObject, eventdata, handles) C=str2double(get(hObject,'String')) setappdata(hObject,'H',C) % --- Executes during object creation, after setting all properties. function edit1_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,

How to pre-set cursor or selection for default answer in input dialog

有些话、适合烂在心里 提交于 2019-12-10 13:56:01
问题 If one creates an inputdialog with inputdlg and a default answer, it looks like that: Which callback command do I need to make it look like that? The documentation is missing a lot here. It's a kind of "luxury service" for the customer ;) But I think it would be nice, if it's easy to implement. This question is actually solved, as I found out that there are convenient functions like uigetfile and uiputfile for my particular case. But the general case of my questions remains unsolved or at