Search Results

Search found 7 results on 1 pages for 'doresoom'.

Page 1/1 | 1 

  • Mean filter in MATLAB without loops or signal processing toolbox

    - by Doresoom
    I need to implement a mean filter on a data set, but I don't have access to the signal processing toolbox. Is there a way to do this without using a for loop? Here's the code I've got working: x=0:.1:10*pi; noise=0.5*(rand(1,length(x))-0.5); y=sin(x)+noise; %generate noisy signal a=10; %specify moving window size my=zeros(1,length(y)-a); for n=a/2+1:length(y)-a/2 my(n-a/2)=mean(y(n-a/2:n+a/2)); %calculate mean for each window end mx=x(a/2+1:end-a/2); %truncate x array to match plot(x,y) hold on plot(mx,my,'r')

    Read the article

  • Replace empty cells with logical 0's before cell2mat in MATLAB

    - by Doresoom
    I've got a cell array of empty cells and ones that I want to convert to a logical array, where the empty cells are zeros. When I use cell2mat, the empty cells are ignored, and I end up with a matrix of solely 1's, with no reference to the previous index they held. Is there a way to perform this operation without using loops? Example code: for n=1:5 %generate sample cell array mycellarray{n}=1; end mycellarray{2}=[] %remove one value for testing Things I've tried: mylogicalarray=logical(cell2mat(mycellarray)); which results in [1,1,1,1], not [1,0,1,1,1]. for n=1:length(mycellarray) if isempty(mycellarray{n}) mycellarray{n}=0; end end mylogicalarray=logical(cell2mat(mycellarray)); which works, but uses loops.

    Read the article

  • MATLAB date selection popup calendar for gui

    - by Doresoom
    Does anyone know of a method to display a popup date selection calendar in a MATLAB gui? I know the financial toolbox has a uicalendar function, but unfortunately I don't have that toolbox. I have a hunch I'm going to have to use some Java or some other language for this one, which I know nothing about. I'm looking for something similar to this: which would return a date string after the user selects the date.

    Read the article

  • How to format output using MATLAB's num2str

    - by Doresoom
    I'm trying to ouput an array of numbers as a string in MATLAB. I know this is easily done using num2str, but I wanted commas followed by a space to separate the numbers, not tabs. The array elements will at most have resolution to the tenths place, but most of them will be integers. Is there a way to format output so that unnecessary trailing zeros are left off? Here's what I've managed to put together: data=[2,3,5.5,4]; datastring=num2str(data,'%.1f, '); datastring=['[',datastring(1:end-1),']'] which gives the output: [2.0, 3.0, 5.5, 4.0] rather than: [2, 3, 5.5, 4] Any suggestions? EDIT: I just realized that I can use strrep to fix this by calling datastring=strrep(datastring,'.0','') but that seems even more kludgey than what I've been doing.

    Read the article

  • How to hide zero values in bar3 plot in MATLAB

    - by Doresoom
    I've got a 2-D histogram (the plot is 3D - several histograms graphed side by side) that I've generated with the bar3 plot command. However, all the zero values show up as flat squares in the x-y plane. Is there a way I can prevent MATLAB from displaying the values? I already tried replacing all zeros with NaNs, but it didn't change anything about the plot. Here's the code I've been experimenting with: x1=normrnd(50,15,100,1); %generate random data to test code x2=normrnd(40,13,100,1); x3=normrnd(65,12,100,1); low=min([x1;x2;x3]); high=max([x1;x2;x3]); y=linspace(low,high,(high-low)/4); %establish consistent bins for histogram z1=hist(x1,y); z2=hist(x2,y); z3=hist(x3,y); z=[z1;z2;z3]'; bar3(z) As you can see, there are quite a few zero values on the plot. Closing the figure and re-plotting after replacing zeros with NaNs seems to change nothing: close z(z==0)=NaN; bar3(z)

    Read the article

  • MATLAB - Delete elements of binary files without loading entire file

    - by Doresoom
    This may be a stupid question, but Google and MATLAB documentation have failed me. I have a rather large binary file (10 GB) that I need to open and delete the last forty million bytes or so. Is there a way to do this without reading the entire file to memory in chunks and printing it out to a new file? It took 6 hours to generate the file, so I'm cringing at the thought of re-reading the whole thing. EDIT: The file is 14,440,000,000 bytes in size. I need to chop it to 14,400,000,000.

    Read the article

  • Return popupmenu selection in MATLAB using one line of code

    - by Doresoom
    I have a GUI which uses a selection from a popupmenu in another callback. Is there a way to return the selected value of the popupmenu in only one line without creating any temporary variables? I've tried several solutions, but I've only managed two lines with one temporary variable: Three lines: list=get(handles.popupmenu1,'String'); val=get(handles.popupmenu1,'Value'); str=list{val}; Two lines: temp=get(handles.popupmenu1,{'String','Value'}); str=temp{1}{temp{2}}; Can anyone shave it down to one? PS, It's a dynamic menu, so I can't just use get(handles.popupmenu1,'Value') and ignore the string component altogether.)

    Read the article

1