Posts

Showing posts from August, 2022

How to MATLAB scatter3, plot3 speed discrepencies

  This is about how MATLAB can take very different times to plot the same thing — and why. I generate 10000 points in 3D space:    X = rand(10000, 1); Y = rand(10000, 1); Z = rand(10000, 1); I then used one of four different methods to plot this, to create a plot like so:  I closed all figures and cleared the workspace between each run to try to ensure fairness. Bulk plotting using scatter3:    >> tic; scatter3(X, Y, Z); drawnow; toc Elapsed time is 0.815450 seconds. Individual plotting using scatter3:    >> tic; hold on; for i = 1:10000 scatter3(X(i), Y(i), Z(i), 'b'); end hold off; drawnow; toc Elapsed time is 51.469547 seconds. Bulk plotting using plot3:    >> tic; plot3(X, Y, Z, 'o'); drawnow; toc Elapsed time is 0.153480 seconds. Individual plotting using plot3:    >> tic; hold on for i = 1:10000 plot3(X(i), Y(i), Z(i), 'o'); end drawnow; toc Elapsed time is 5.854662 seconds. What is it that MATLAB does behind the scenes in t

How to open DBase files (.DBF) in Matlab?

  I've googled and searched through Matlab Central, but cannot find any way to open DBF files directly in Matlab. There are some references to DBFREAD function in TMW File Exchange, but it's not available anymore. Is it really a problem? I do have Database toolbox, but could not find dbf support there. I don't want to use Excel or other tools for converting files outside of Matlab, since I have a lot of files to process. ODBC also is not good, I need the code to work under Mac and Unix as well. Please help.   NOTE:- Matlabhelpers.com  provide latest  MatLab Homework Help, MatLab Assignment Help  ,  Finance Assignment Help  for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.     Answers:  10   I contacted with Brian Madsen, the author of DBFREAD function, which

Why do I get a "Too many input arguments" error when not passing any?

  I am working on some simple object-oriented code in MATLAB. I am trying to call one of my class methods with no input or output arguments in its definition. Function definition: function roll_dice Function call: obj.roll_dice; When this is executed, MATLAB says:    ??? Error using ==> roll_dice Too many input arguments. Error in ==> DiceSet>Diceset.Diceset at 11 obj.roll_dice; (etc...) Anyone have any ideas what could be causing it? Are there secret automatic arguments I'm unaware that I'm passing?   NOTE:- Matlabsolutions.com  provide latest  MatLab Homework Help, MatLab Assignment Help  ,  Finance Assignment Help  for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.     Answers:  When you make the call:    obj.roll_dice; It is actually equivalent to:

How to MATLAB: Extract multiple parts of a matrix without using loops

  I have a huge 2D matrix and I would like to extract 15 different 100x100 parts out of it. I have two vectors x and y where the top left indices of the parts are saved. I have used something like this:    result = cam1(x(1:end):(x(1:end)+99), y(1:end):(y(1:end)+99)); but the result is just a 100x100 matrix instead of a 15x100x100. Why? I know it could easily be done using a loop but we are not allowed to use loops (it's part of an image processing exercise). Another possbility would be to write all the 15 lines but that is kind of ugly. Do you have any elegant solution? Thanks.   NOTE:- Matlabsolutions.com  provide latest  MatLab Homework Help, MatLab Assignment Help  ,  Finance Assignment Help  for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.    Answers:  There

How to make a Gaussian filter in Matlab

  I have tried to make a Gaussian filter in Matlab without using  imfilter()  and  fspecial() . I have tried this but result is not like the one I have with imfilter and fspecial. Here is my codes.    function Gaussian_filtered = Gauss(image_x, sigma) % for single axis % http://en.wikipedia.org/wiki/Gaussian_filter Gaussian_filtered = exp(-image_x^2/(2*sigma^2)) / (sigma*sqrt(2*pi)); end for 2D Gaussian,    function h = Gaussian2D(hsize, sigma) n1 = hsize; n2 = hsize; for i = 1 : n2 for j = 1 : n1 % size is 10; % -5<center<5 area is covered. c = [j-(n1+1)/2 i-(n2+1)/2]'; % A product of both axes is 2D Gaussian filtering h(i,j) = Gauss(c(1), sigma)*Gauss(c(2), sigma); end end end and the final one is    function Filtered = GaussianFilter(ImageData, hsize, sigma) %Get the result of Gaussian filter_ = Gaussian2D(hsize, sigma); %check image [r, c] = size(ImageData); Filtered = zeros(r, c)

How to Simplifying a very long symbolic expression by automatically introducing temporal variables or in any other way

  After attempting to solve a symbolic math problem, I got an expression with about 17000 characters. I am using the symbolic toolbox for Matlab, but I am open to any suggestion (Mathematica, whatever). For obvious reasons, I won't copy-paste the expression straight into the question.  Here is a link instead . Running the  Matlab  commands  simplify  and  simple , and even attempts to  collect  didn't improve the situation (Some got it worse). But I am wondering, I don't care if the expression is evaluated in steps, with temporal parameters. Something like:    z1 = a^2*y1; %Now the expression can be simplified by using z1 as alias! z1+z1^2 .... Is there an automatic method to get such a step-by-step simplification with temporal variables? Also, any other method that you can think of is plausible.  NOTE:- Matlabsolutions.com  provide latest  MatLab Homework Help, MatLab Assignment Help  ,  Finance Assignment Help  for students, engineers and researchers in Multiple Branche

How do I resize a matrix in MATLAB?

  Suppose I had a  1-by-12  matrix and I wanted to resize it to a  4-by-3  matrix. How could I do this? My current solution is kind of ugly:  for n = 1:(length(mat)/3) out(n,1:3) = mat( ((n-1)*3 + 1):((n-1)*3 + 3) ); Is there a better way to do this?   NOTE:- Matlabsolutions.com  provide latest  MatLab Homework Help, MatLab Assignment Help  ,  Finance Assignment Help  for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.   Answers:  reshape  is of course the proper solution, as stated by @gnovice. A nice feature of  reshape  is that it allows this:    A = 1:12; B = reshape(A,4,[]); B = 1 5 9 2 6 10 3 7 11 4 8 12 So if you don't know how many columns there will be,  reshape  will compute it for you. Likewise,  reshape

How to Cross-correlation in matlab without using the inbuilt function?

  can someone tell how to do the cross-correlation of two speech signals (each of 40,000 samples) in MATLAB without using the built-in function  xcorr  and the correlation coefficient? Thanks in advance.  NOTE:- Matlabsolutions.com  provide latest  MatLab Homework Help, MatLab Assignment Help  ,  Finance Assignment Help  for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.       Answers:  You can do cross-correlations using  fft . The cross-correlation of two vectors is simply the product of their respective Fourier transforms, with one of the transforms conjugated. Example:    a=rand(5,1); b=rand(5,1); corrLength=length(a)+length(b)-1; c=fftshift(ifft(fft(a,corrLength).*conj(fft(b,corrLength)))); SEE COMPLETE ANSWER CLICK THE LINK    https://matlabhelpers.com/questions/

How to set the plot in matlab to a specific size?

  Generally, I wish to plot a rather complex x-y plot (lots of overlapping curves) to an A3 format so:    A4 210x297 A3 = A4*2 = 420 x 297 ... - 10mm each side = 400 x 277 (size of desired plot window) What is the easiest way to set the size of the plot so it fits that size when printed in PDF (or any other common output format)?   NOTE:- Matlabsolutions.com  provide latest  MatLab Homework Help, MatLab Assignment Help  ,  Finance Assignment Help  for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.     Answers:  As @LewisNorton explained, you need to set the  Paper***  properties of the figure. Below is an example for producing a PDF file with dimensions  420 x 297 mm  (A3 size), where the margins between the plot and the file borders are  10 mm  each (top,bottom,left