matlab

matlab problem in plotting a function

I have 2 functions: f (aa) = 9 sinaa/aa + cosaa for 0 <= aa <= 6pi. --- >equation 1. and f(aa) = cosku I need to plot the allowed values of aa which will satisfy the equation 1. How do i do this i matlab? ...

Logical error in matlab(Edit)

EDIT:- a4 = 10*magic(4); a5 = magic(5); a4 a5 diag4 = sub2ind([4,4], 1:3,1:3); diag5 = sub2ind([5,5], 1:3,1:3); a5(diag5) = a4(diag4) #Display changed contents diag4 %# Display diagonal of magic4 diag5 %# Display diagonal of magic5 a4(diag4)=a5(diag5) %# recovering the original The output is a4 = ...

How can I continue with a loop when an error occurs in MATLAB?

I'm converting some .dat files into .mat files using a function. I'm calling this function inside a loop to convert a number of files. There are some cases where my .dat file is corrupted and the function cannot convert and an error occurs, stopping the loop. Now my question is: Is there any command wherein when the error occurs it shou...

i want to know how to compute the sum of some elements in a matrix with the loop statements

I want to calculate the sum of the elements in a matrix that are divisible by 2 . How do I do it? And how do I output the ans in a co-ordinate form? ...

What is D and P of a Matrix ?

Just read something where it says to decompose a vector, say A. [U S V]=svds(A,2). Now, the document says to use the D and P of the decomposed vector in some other function. I guess, D is the diagonal elements S. What is P indicate ? I guess, its a stupid question but I just cant figure it out. ...

How do I get the second return value from a function without using temporary variables?

I have a function that returns two values, like so: [a b] = myfunc(x) Is there a way to get the second return value without using a temporary variable, and without altering the function? What I'm looking for is something like this: abs(secondreturnvalue(myfunc(x))) ...

Create inverse logical array in Matlab

I have a logical array, isLand, that is true if the index is over land and false if the index is not over land, like the ocean. How can I easily create another logical array, isOcean, which is the inverse of isLand. All the ones in isLand will be zeros in isOcean and vice versa. I know I can do this using a for loop but I feel there is...

A Matlab code for Random way point in MANET

Just started reading on random way point mobility for MANET. I found a lot of work implements this model. Hence, I assumed the Matlab code will be available which I could look into to understand it better. Unfortunately, I found none. Any body can suggest any good tutorial or codes available on random way point ? Help appreciated. UP...

How can I plot an image (.jpg) in MATLAB in both 2-D and 3-D?

I have a 2-D scatter plot and at the origin I want to display an image (not a colorful square, but an actual picture). Is there any way to do this? I also will be plotting a 3-D sphere in which I would like an image to be displayed at the origin as well. ...

Is it possible to reproduce randn() of MATLAB with NumPy?

Hi, I wonder if it is possible to exactly reproduce the whole sequence of randn() of MATLAB with NumPy. I coded my own routine with Python/Numpy, and it is giving me a little bit different results from the MATLAB code somebody else did, and I am having hard time finding out where it is coming from because of different random draws. I h...

Matlab, a binary image with non-uniform object to enlage

I have binary image with non-uniform object. I want to extend this object with 2 pixels around the object's border. What is the best way to enlarge the object using Matlab? ...

How to enable matlab to listen real time data through c++ application

Hi, I need to create a c++ add-in to mathlab where add-in will listen to packet coming from network and notify mathlab to draw an packet analysis graph. I understood that using a MEX file I can easily call c functions inside mathlab, but I could not find a way to notify mathlab when data is available at c++ end. Is there any way we can ...

How to change the format of the numbers displayed on an axis in a MATLAB plot?

I actually have 3 questions: I have a plot with data that is in the thousands and my plot's axis is diplaying the tick marks as .4 .8 1.0 1.2 and a *10^4 in the lower right. This is a little annoying. Besides dividing my data by 1000 or hardcodig the tick marks is there a way to change to tick marks from .4*10^4 TO 4000? Seems li...

How to add a pointer to a 3-D plot in MATLAB?

I want to plot a "Pointer" in a 3-D plot. I want this "pointer" to point at a certain spot on a sphere that I have graphed. This pointer does not have to have an arrowhead but would be nice if it did. Is the only way to plot a line with a jpg at the end? Not too sure... Thanks for any help! ME ...

How can I concatenate ranges of numbers into an array in MATLAB?

For example, I want to combine two ranges of numbers like this: 1 2 3 4 5 11 12 13 14 15 16 17 18 19 20 So, I tried: a = 1:5,11:20 but that didn't work. I also want to do this in a non-hardcoded way so that the missing 5 elements can start at any index. ...

Why isn't this inverse Fourier transform giving the correct results?

I want to invert the Fourier transform of an image in MATLAB, but the result is not the original image (as it should be). There is obviously some implementation detail that I don't know about that's causing the issue. Here's the code: img = imread('img.jpg'); fft = fft2(img); inv = ifft2(fft); imshow(inv); ...

How do I get the index of the smallest element in an array in matlab?

How do I get the index of the smallest element in an array in matlab? ...

Is there a Python equivalent of MATLAB's conv2 function?

Does Python or any of its modules have an equivalent of MATLAB's conv2 function? More specifically, I'm interested in something that does the same computation as conv2(A, B, 'same') in MATLAB. ...

Matlab + Java: java.lang.ExceptionInInitializerError when trying to use javabuilder

Hello, I've been trying to use Matlab's javabuilder package under Windows XP, but I'm getting a strange error when trying to instantiate any javabuilder class. To illustrate the problem, I've created a simple program that prints the MCRROOT and PATH system variables (to check if they're correctly set) and tries to create a MWCharArray: ...

How to compare different distribution means with reference truth value in Matlab?

I have production (q) values from 4 different methods stored in the 4 matrices. Each of the 4 matrices contains q values from a different method as: Matrix_1 = 1 row x 20 column Matrix_2 = 100 rows x 20 columns Matrix_3 = 100 rows x 20 columns Matrix_4 = 100 rows x 20 columns The number of columns indicate the number of years. ...