Skip to content

comp.soft-sys.matlab

Home arrow Newsgroups arrow comp.soft-sys.matlab


comp.soft-sys.matlab
The MathWorks calculation and visualization package.

  • show pixel grid
    I'd like to produce an effect like this - where each pixel outline can be seen even if the pixels are similar values.
    [link]
    Is there a built in way to do this with matlab or the image processing toolbox?
    Thanks
    Dave

  • Re: cumulative maximum - vectorised
    Typo:
    Bruno

  • Re: convolution
    Try to think why the above gives length 4, and not 2 nor 5 (=4+2-1).
    Bruno

  • Re: cumulative maximum - vectorised
    Hah hah very funny Jos, but why try to make us by statistic toolbox:
    A = [2 1 3 5 4]
    fliplr(max(toeplitz(A,-inf(siz e(A)))))
    Bruno

  • Re: convolution
    this gives the ans y=[11 8 5 2] that has the length of 4 but i just want length of 2.bec inputx[n] has length of 2...

  • processing an image in blocks
    hi!
    I am doing a project of FPGA based image compression using DCT.I want to divide an image into blocks of 8x8 matrix.
    These blocks are then going to be given as input to the FPGA kit connected to the PC.The FPGA kit will process on those 8x8 matrix blocks and produce processed outputs in the form of new 8x8 matrix blocks.

  • Re: cumulative maximum - vectorised
    Take a look at SLIDEFUN
    a = [2 1 3 5 4]
    slidefun(@max,numel(a),a,'back ward')
    % ans = 2 2 3 5 5
    SLIDEFUN can be found here:
    [link]
    Although SLIDEFUN is not vectorized, it is quite efficient.
    Possible oneliners for this particular problem include:

  • Re: cumulative maximum - vectorised
    I doubt this is worth posting on the
    FEX, but it does work on any specified
    dimension.
    function res = cummax(V,dim)
    % cummax: cumulative maximum
    % usage: res = cummax(V)
    % usage: res = cummax(V,dim)
    %
    % Arguments: (input)
    % V - any numeric vector or array
    %
    % dim - (OPTIONAL) - scalar positive integer

  • Re: cumulative maximum - vectorised
    This is something I've wanted before. I looked
    at the idea of a descending sort, then using
    those tags to create the cumulative max. Its
    too unwieldy to be more efficient as Matlab
    code. And since a sort does more work than
    this requires, why bother? Finally, while a mex
    would surely gain some speed, an accelerated,

  • reading a data file to searches on Date
    Hi,
    I wanted to read in a file with the following format
    Date number number
    where date is a string such as "4-Oct-08" and numbers are floating point.
    I want to be able to do some searches (using find) on the Date. How do I read in the file such that I can do the searches on the date ?
    Many thanks.

  • Re: Cannot run a custom function
    I checked it and it was not the case. As a matter of fact, the same script containing the custom function was running fine for a while. It all of the sudden stopped working.
    Thanks for the feedback.
    Ron

  • ??? Error using ==> movie
    hi, i have created a movie and the computation is fine (but extremely slow), but after the computation, it stopped about half way and an error appeared:
    ??? Error using ==> movie
    Could not create movie frame
    Error in ==> rtani_1 at 40
    movie(Z,1);
    Here is my code, it is about a helicopter with slung-load, and x0 is a simulation results from Dynamic equations (has 1001 length), and my code creates 1000 frames, it takes extremely long time to compute it, does anyone have any idea to reduce the computing time? also how to avoid that error? By the way, it is fine for movie2avi, again, it takes few mins to do it, so how to reduce the time?

  • Re: 1 variable in 2 mexfunctions
    Could please someone explain me a little more about making a DLL library that I could use for my problem?
    I tried using the first method described here and I was able to transfer the matrix to the GPU memory, keep it there and get the address of the matrix returned to matlab as variable. But I was not able to use thet pointer in the second function because I was not able to get the right value of the matrix address into the second function through mexFunction that accepts only mxArray types.

  • action button Simulink Mask Subsystem
    Hi all,
    I would like to ask You if anybody know how to add action button to Mask...
    for example as in Digital Filter Block, where is button View filter response, I would like to make some simmilar block.
    thanks for reply

  • Re: cumulative maximum - vectorised
    Why it has to be vectorized?
    I'm curious to see any vectorized algorithm one can beat this one:
    function b=cummaxfor(a)
    b=zeros(size(a));
    b(1)=a(1);
    for k=2:length(a)
    b(k)=max(a(k),b(k-1));
    end
    To gain speed, make a Mex.
    Bruno

  • Re: Odometer Step Problem
    Sorry for posing such an ill-phrased question.
    Say for odoprob([3;3;3;3;1;1;1],2)
    ans =
    2 0 0 0 0 0 0
    1 1 0 0 0 0 0
    0 2 0 0 0 0 0
    1 0 1 0 0 0 0
    0 1 1 0 0 0 0

  • cumulative maximum - vectorised
    Dear All,
    I would like to calculate the cumulative maximum of a vector. This should work exactly like cumsum but taking max instead of sum. (E.g. cummax([2 1 3 5 4])is [2 2 3 5 5]) Of course the challenge is to do this in a vectorised way.
    My first attempt was
    %----------------------------- ------------------------------ --

  • Modelling dynamic systems
    Hi everyone
    I need ur help on this one
    I am developing a control system (PID based) for a fixed wing aircraft. For that i need to develop a model of a plane in simulink so can any one help me out how to do that??
    Thanks in advance

  • Re: vectorized solution
    you might want to try accumarray. I have not checked whether this is faster than previous solutions. Note that indices in subs can be missing and must not be in any order.
    Regards,
    gg
    %----------------------------- ------------------------------
    Vec1 = [2 2 1 5 2 2 3 1 3 5 5 5 2 5 5 5]';
    Vec2 = rand(length(Vec1),1);

  • Re: robust power spectral analysis?
    thank you very much for the comments, Rune. I basically completely agree with you.

  • Re: robust power spectral analysis?
    thanks for the recommendation, Vincent. however, to be honest, the demo is not satisfying to me. basically, I don't have any difficulty in conducting basic power spectrum analysis, but I really hope to understand/grasp all the details of the technique. specifically, how to test the result of the spectral analysis? any hint to me? cheers...zhiyu

  • Re: function handle
    OMG, I just saw that I copied my code wrong. These first 2 lines aren't comments, they go:
    f=@(u)u;
    h=@(u)nn(u,x,size(y,1));
    And there is where the error appears. Can somebody help me now?

  • Matlab not working for domain admin
    I had installed Matlab 2008a in two computers that have been ghosted in two labs. Computers are members of Active Directory (W2K3 native). Matlab works fine for local user, local admin and domain user, BUT not for domain admin.
    For domain admin the starting procedure ends with error
    (without showing the initial Matlab picture.) Dr Watson starts with folloing data:

  • Re: C++ Engine Array Size Limits?
    Well, a variable that contains 50,000,000 doubles needs at least
    400,000,000 mytes of memory. In a 32 bit OS the memory limit is
    2 GBytes, which is enough to hold at most 5 such variables.
    On a single-core system the 2GB will also accomodate the matlab
    executable, the OS as well as all the non-related executables

  • how to store extracted feature
    hi to all.
    i am working on Speech emotion recognition using SVM.
    i am using matlab's colea toolbox for extracing the features like
    pitch and formanant frequencies. but dont know how to store them in a
    single database for training and recognition. plz help me out...
    n also sugest any another tool for feature extraction....

  • Re: Comparison
    At each for loop iteration you should compare a substring of t with p.
    What you did is just comparing one (1) character of each.
    Bruno

  • Re: convolution
    x=[1 2]
    h=[4 3 2 1]
    y=conv2(h,x,'same')

  • Re: convolution
    con2 gives 2d ans
    but i want only 1d
    my question is that
    let suppose
    x[n]=[1 2] %input
    h[n]=[4 3 2 1] % impluse response
    y[n]=conv(h,x); %
    in this case y[n] has length of 5 but i just want that y[n] has same length as input(e.g 2 in this case)
    please suggest me some way out of this
    thanks

  • Re: Comparison
    Try ismember and strcmp functions.

  • Re: convolution
    Use conv2 with the third option instead.
    Bruno

  • Comparison
    I am trying to run naive string matching in MATLAB..dont know where i am going wrong..have got fed up and finally thought of writing for some help on the forum.. The following is my code..It seems to be working for a single word as a pattern but when it comes to more than one word..it fails..I am sure there is some logical problem..just getting tired of not able to code such simple programs ..some one please try to help me conceptually if possible..i am new to programming and i m finding life really tough..

  • Re: Odometer Step Problem
    Ian wrote:
    Your original question is ill-posed. What output exactly do you want?
    An example please, complete with (short) realistic input so that we can
    do test runs.

  • Re: IEEE 754 support
    Which -part- of IEEE 754 ? Matlab does not support decimal arithmetic, and
    does not offer control over rounding modes except under MS Windows.

  • Re: Cannot run a custom function
    Ummm maybe you confused the name of the function with its file name. For example in the CustomFunction.m file the function has a different function [ output ] = name( input ).

  • convolution
    "i want to implement the convolution function using matlab that produces the output whose length is same as input".
    i am using the CONV function but it produces the output whose length is
    outputlength= inputlength +impluse response length-1
    please help me

  • Re: Circuit Breaker
    Gibo
    If the breaker is already energized, you can not open it by the internal time you set. I do not know why.
    You just have to use switching device.
    Gibo

  • Cannot run a custom function
    I am using R2007a and have written a few custom functions. They worked for a while, but suddenly ceased to work. I got the following error message:
    ??? Undefined function or variable 'CustomFunction'.
    or
    ??? Undefined function or method 'CustomFunction' for input arguments of type 'double'.
    It acted as if the directory where the fuction resides was not recognized, even though I made the directory current. I also tried to reset the path, but to no avail.

  • Re: PCA
    Hi, Alaa,
    Can you send the code to me?
    My email is: weyoung...@163.com
    Thank you very much!
    sincerely
    Yang

  • Start Multiple Instances Of A Function From Matlab
    I want to start multiple instances of a function running from one matlab instance. Does any one know if there is a way to do this. For example:
    If I have a function that takes 2 arguments I want to start 4 times on different threads as follows:
    Start(fun,arg1,arg2a);
    Start(fun,arg1,arg2b);
    Start(fun,arg1,arg2c);

  • Optimization algorithm
    This is probably a very simple question for those who have done this before.
    I have a function that sorta looks like this:
    f(x)= 1/sin(x+a1) + 1/(sin(x+a2) + 1/(sin(x+a3) + 1/(sin(x+a4)
    a1,a2,a3,a4 are allowed values between 0 and pi.
    Now what I want to do is find the values of a1, a2, a3 and a4 such that the derivative of f(x) best approximate another function g(x) for a certain range of values of x.

  • Re: C++ Engine Array Size Limits?
    Some observations from some quick tests on a WinXP system:
    Largest contiguous blocks (feature memstats):
    938MB
    851MB
    238MB
    etc.
    I opened a C program and created a 425MB array and put it into the engine successfully. However, when I tried a 426MB array it failed. So, interestingly, 425MB x 2 is just under the 851MB block available, and 426MB x 2 is just over the 851MB block available. My preliminary conclusion is that there *is* a hidden limitation with the COM interface here and an extra copy in the same block is needed in the background to do the copy. I will try to look at the doc to see if there are any engine/COM limitations listed there.

  • Partial derivative
    First of all, I have a complicated multi-variable integral. like:
    f(x,y,z) = integral(x..., y..., z...)
    This integral cannot be integral out to a simple expression. I can get a certain result through numerical integral quad(x, Xmin, Xmax) for giving certain values to y and z.
    Now, I want to have get the partial derivative of f with respective to y or z. I tried diff(), and gradient(). Both of them can not give me a none integral function.

  • Re: C++ Engine Array Size Limits?
    "James Tursa"
    I misstated the amount, it is actually 5.6 million doubles, so only 45mb or so. I will look into contiguous memmoy, however I am able to go to the command window right after the call fails and create an array 10 times that size.

  • I cannot close my model in Simulink at end of my simulation
    I run my simulation and I read my results. Ok
    I try to close the model at end but there is popup:
    'Cannot close the model 'example' while processing a callback'
    What it means?
    How can I stop that callback?
    What is it that callback?
    Thanks.

  • Re: Embedded Matlab in Simulink to find a zero by bisection method
    There is no technical impediment to implementing FZERO or a bisection
    algorithm within an Embedded MATLAB block. However, if you don't need to
    generate code with RealTime Workshop, here is how to call a "FunFun" like
    FZERO from an Embedded MATLAB block:
    %%% Begin Embedded MATLAB Block.
    function y = fcn(a,b) %#eml

  • Re: Is it possible to optimize a spline function?
    Yes. A spline is a piecewise polynomial model,
    that approximates your function from your
    data points. The knots or break points specify
    the locations where the pieces are tied together.
    Why should there be a problem?
    There is no such constraint on a spline such
    that it satisfies any convexity constraints, at

  • Re: C++ Engine Array Size Limits?
    That's 400MB per mxArray. How many mxArray variables are you working with? How much RAM do you have? What is the largest contiguous block of memory that your have available? Etc. Etc. Note that the engine will have a separate copy of the variable, so this doubles the amount of memory required for each copy. Unless you are freeing memory on the C++ side as you go this can double everything up.

  • Re: Interesting Triangular 3D Mesh texturing situation
    What you were doing isn't exactly "texture mapping", since patch objects don't support that. I'm guessing you were setting the CData property of the patch object. You should check the MATLAB documentation regarding this patch property. It indicates how you can add one color per triangular face (i.e. each face has a flat color, I believe) or one color per vertex, which I think is what you were doing which gave you the image you had linked to. This isn't exactly like texture mapping, where you can map multiple colored pixels to a face, but it's the best you can do with patches as far as I know.

  • Re: robust power spectral analysis?
    Data analysis is an assembly of several techniques
    which are chosen subjectively absed on whatever
    adata are to be analyzed, the context of the analysis,
    and the personal preferences of the analyst.
    It takes time and effort to build enough experience
    to select tools for any given job, so your confusion

  • Re: Is it possible to optimize a spline function?
    Thank you for your reply. My understanding for the spline approximation, which might be wrong, is that the whole region, if necessary, is seperated into different regions and each region is represented by a polynomial function. In that case, will there be any problem with optimizing each region and then comparing the optimums to get the global optimum? I guess there is a question sort of embeded in this question, which is whether the polynomial function is always convex at the positive variable region (since variables are positive in my problem).