matlab

How to save data in .txt file in MATLAB

I have 3 txt files s1.txt, s2.txt, s3.txt.Each have the same format and number of data.I want to combine only the second column of each of the 3 files into one file. Before I combine the data, I sorted it according to the 1st column: UnSorted file: s1.txt s2.txt s3.txt 1 23 2 33 3 22 4 32 4 32 2 11 5 22 1 10 ...

FFT in MATLAB: wrong 0Hz frequency

Hello I want to use fft in MATLAB to analize some exprimental data saved as an excell file. my code: A=xlsread('Book.xls'); G=A'; x=G(2, : ); N=length(x); F=[-N/2:N/2-1]/N; X = abs(fft(x-mean(x),N)) X = fftshift(X); plot(F,X) But it plots a graph with a large 0Hz wrong component, my true frequency is about 395Hz and it is not shown i...

MATLAB submatrix over variable dimensions

I have a variable dimension matrix, X. I want a function that will get the first half of X in one dimension. I.E., I want something like this: function x = variableSubmatrix(x, d) if d == 1 switch ndims(x) case 1 x = x(1:end/2); case 2 x = x(1:end/2, :); cas...

Matlab editor not using emacs shortcuts

Hi Is there some way I can make the matlab integrated editor not use emacs shortcut, but use more normal shortcuts such that I can press CTRL-c and CTRL-v and not be completely confused by the editor doing weird stuff? I'm using matlab on linux btw. ...

problem with sortrows MATLAB

Hi, My question is related with the previous solved question in http://stackoverflow.com/questions/2925623/how-to-save-data-in-txt-file-in-matlab. my problem is that, I decided to unsorted the output, however this error comes out when I removed the sortrows---'Input files have different number of rows' And no error when I leave the so...

Matlab Error- fplot();

>> fplot(fh,[-2 4]) ??? Undefined function or variable "e". Error in ==> myfun at 3 Y(:,2) = e(:).^x; Error in ==> fplot at 102 x = xmin; y = feval(fun,x,args{4:end}); I tried to plot two function using this m file. function Y = myfun(x) Y(:,1) = 3*x; Y(:,2) = e(:).^x; ...

Type, size, dimensions of an image in matlab

hi, I want to retrieve Type, size, dimensions of an image in matlab. ...

MATLAB clear current figure

I want to clear MATLAB's global CurrentFigure property, because I need a plot that I make to not be overwritten if a careless user uses plot without opening a new figure. I tried set(0, 'CurrentFigure', []); But it doesn't seem to work. Is this impossible? ...

Matlab code help. Backward Euler method.

Here is the matlab/freemat code I got to solve ODE numerically using backward Euler method. However the results are inconsistent with my textbook results, and sometimes even ridiculously inconsistent. Please point out what is wrong with the code. I have already asked this question on mathoverflow.com no help there, hope someone here can...

how to implement simple Sliding Window Algorithm in Matlab or C++

hello to every one, i am new one to this site and this is my first query... i need simple Sliding window algorithm implementation in c++ or matlab please help me in this regard thanks ...

change resolution in matlab

if i have an image with a black and big frame, how can i take it off? ...

Extracting data points from a matrix and saving them in different matrixes in MATLAB

Hi, I have a 2D Matrix consisting of some coordinates as below(example): Data(X,Y): 45.987543423,5.35000964 52.987544223,5,98765234 Also I have an array consisting of some integers >=0 , for example: Cluster(M) 2,0,3,1 each of these numbers in this array corresponds with a row of my 2D Matrix above.For example, it says that row one...

Matlab GUI - How to get the previous value entered from a callback function?

Hi, I know that this is probably a simple problem but I am new to Matlab GUI's and basically want to get the old value which used to be stored in the text box to replace the value which has just been entered. E.g. Text box contains a valid string, User enters invalid string, Callback func, validates input and realises new input is an ...

How to create a cell array of k similar objects in Matlab?

I want to create an 1,k cell of m,m matrices. I have some trouble trying to initialize it. My first idea was to do this myCell = cell{1,K}; for k = 1:K myCell{1,k} = eye(m); end But it seems like such ugly way to initialize it. There have to be a better way? ...

how can i write f(first,y) in matlab?

can you please help me?, i can't explain my question clearly, I define x & y ,i can write plot(f(end,y)) ,but I want to know that how can i must type this code for f(first,y)?thank you! ...

MATLAB Builder NE crash apppool on IIS 7.5

I'm developing a web user interface for MATLAB functions with ASP.NET. I've started with studying demos and stucked with such problem. I created a MyComponent.dll assembly with deploytool from MATLAB 2010a, target framework - 3.5. This component has one function GetKnot() which returns a figure. function df = getKnot() f = figure...

Matlab 3d volume visualization and 3d overlay

Hi, so the question ist pretty much the title. I have a 3d volume loaded as raw data [256, 256, 256] = size(A). It contains only values of zero's and ones, where the 1's represent the structure and 0's the "air". I want to visualize the structure in matlab and then run an algorithm on it and put an overlay on it, let's say in the color ...

How can i interpret a time value in ascii into a numerical value?

I have a file which is as follows: 15:03:21 II 0.88 0.64 15:03:31 II 0.88 0.64 15:03:42 II 0.40 0.40 etc. after loading the file in matlab, I want to be able to read the first column (which corresponds to time) and interpret them as numerical values. At the moment, they are interpreted as a string of ascii characters ...

Strange Matlab error: "??? Subscript indices must either be real positive integers or logicals"

I have a function func that returns a vector a. I usually plot a and then perform further analysis on it. I have a certain scenario when once I try to plot a, I get a "??? Subscript indices must either be real positive integers or logicals" error. Take a look at the following piece of code to see the vector's behavior: K>> a a = 5....

Drawing and filling different polygons at the same time in MATLAB

Hi,I have the code below. It load a CSV file into memory. This file contains the coordinates for different polygons.Each row of this file has X,Y coordinates and a string which tells that to which polygon this datapoint belongs. for example a polygone named "Poly1" with 100 data points has 100 rows in this file like : Poly1,X1,Y1 Poly...