Answered
Avoiding for loops problem
If you have the Statistics Toolbox, you can use the PDIST2 function. It is very fast. A = rand(200,100); B = rand(300,10...

12 years ago | 1

Answered
Simulink Decreasing Constant over Time
Here are two ways to do it: 1. [Ramp] --> [Saturation] --> 2. Use the Signal Builder block (works for more complicated pie...

12 years ago | 0

| accepted

Answered
Deleting rows and columns of all zeroes in a symbolic matrix
syms x1 data = [ x1, 1, 0 ; 0, 0, 0 ; 0, 1, 0] data( all( isAlways(data==0) ,2) ,:) = [] data( : ,all( isAlways(data=...

12 years ago | 0

| accepted

Answered
Vectorization of product of flipped vectors
Faster for long vectors, slower for short ones: r = conv(r1,r2); r = r(1:numel(r1));

13 years ago | 0

| accepted

Answered
Use interp2 for many simultanious 1D operations?
As others have also pointed out, this is *REALLY* not what INTERP2 is meant to do. In fact if anything, since there are 3 variab...

13 years ago | 0

Answered
Common Volume/Intersection Volume between two Delaunay Triangulations
Sounds like a difficult problem to do exactly/analytically. I think you can get a very good approximation using a much simpler m...

13 years ago | 1

Answered
using lsqlin when you have a large matrix
I don't think there is anything wrong with this code, except LSQNONNEG would be easier. coef = lsqlin(x,yt2,-a,-b); is t...

13 years ago | 0

| accepted

Answered
Volume integration under surface fitting
Since your points only cover that parabolic looking region in X-Y, how is MATLAB supposed to know what the values of the functio...

13 years ago | 0

| accepted

Answered
how find ramp response
You could get the ramp response by dividing your transfer function by s, and then taking the step response. For example: ...

13 years ago | 14

| accepted

Answered
discrete second order derivative operator for unequally spaced data
Could you possibly use the GRADIENT command? This allows you to pass in unevenly spaced values for X and Y. help gradient

13 years ago | 0

Answered
Integrating a multivariate function w.r.t. a single variable
Define another function handle to be the integral over y. Like this: % Just making some random 2d function f = @(x,y) (x...

13 years ago | 4

| accepted

Answered
If I have a 3d matrix(A), how can i check if a given 2d matrix(B) is one of matrix A's pages?
Given a 3d matrix A: A = cat(3, [1 2; 3 4], [5 6; 3 4], [5 6; 1 2]) And some 2d matrix B B = [5 6; 3 4] Then, th...

13 years ago | 2

Answered
Polynomial fitting of each pixel in an image without looping
Here's an approach using sparse matrices to do it. this works in about 0.3 seconds for me, and gives the coefficients in a 5x655...

13 years ago | 0

Answered
Find Critical Mach number graphically
You probably just need to change "/" to "./" Remember, the dot indicates elementwise operations. This works: 1./[1 2...

13 years ago | 0

Answered
Calculating integral but weird result :S
When sigmaZ is negative, the integrand blows up around x = 0.3 and x = 2.7 and you have a singularity which you cannot integrate...

13 years ago | 0

| accepted

Answered
get line plot data just by mouse stay on it (without click)
Here is a simple example that outlines how to do it using HITTEST. function my_example plot(rand(5)); set(gcf,'wi...

13 years ago | 0

| accepted

Answered
Matlab matrix operations without loops
Your entire script is equivalent to this: M_MAX = 1000; N_MAX = 2000; YTemp = (1:M_MAX)'*(1:N_MAX);

13 years ago | 1

Answered
how can I select a part of data with dual cousors and get the average in a curve?
I think the simplest way to do this would be to use the brush feature. 1. Plot your data 2. From the figure toolbar, selec...

13 years ago | 0

Answered
continuous search of the closest rows in a matrix
If you have the Statistics Toolbox installed, instead of using PDIST2, use PDIST (along with SQUAREFORM) instead. It is designed...

13 years ago | 0

Answered
Creating a spherical matrix
Something like this? Rx = 1; %<-- Change these to make an ellipse instead Ry = 1; %<-- Change these to make an ellipse ...

13 years ago | 1

Answered
were to introduce hold on command
You keep overwriting "nim" with the same original "k". You can fix it easily: *Step 1.* Change these lines: ok = 0; w...

13 years ago | 0

| accepted

Answered
Double integral with singularity
I will change my earlier comment into an answer: Look at these two lines: funGLA = quad2d(GLA, 0.05, ta(mt), xi(1), xi(en...

13 years ago | 0

| accepted

Answered
how to block diagonalize a 3D matrix
R = rand(4,2,3); M = mat2cell(R,4,2,ones(1,size(R,3))); M = blkdiag(M{:})

13 years ago | 0

Answered
problem with calculation of percentage of colormap
You don't need to loop over every element one by one to do this. MATLAB is very good at doing operations on entire matrices in o...

13 years ago | 0

Answered
The error 'Matrix dimensions must agree' during optimization.How can it be solved?
The problem occurs when K1 is negative. The ODE solver blows up before it can integrate to all your time values. You should spec...

13 years ago | 0

| accepted

Answered
Coherence of two signals
The coherence is a function of frequency, and in general it will not have the same number of elements as the original (split up)...

13 years ago | 0

| accepted

Answered
parameterized function of quadgk with another array input argument
You could try to use an ODE solver instead of just a scalar integration function. For example. %% Just make some random array...

13 years ago | 0

Answered
how to print the values of each bar on top of it; multibar and subplots
Would something like this work? Data1 = [1 2 0 3 4]; Data2 = [2 3 4 5 5]; hb = bar([Data1;Data2]); % Find the ...

13 years ago | 1

Answered
How to plot a second graph instead of color-coding
Assumung your XY data are smooth, you can find the normal vector at each point, and then offset in that direction, like the code...

13 years ago | 1

| accepted

Answered
help me to solve this second order non-linear differential eq?
Well you're almost there Rewrite this: y(2)=y'(1) y'(2)+a*sign*y'(1)*|y'(1)|^1.8+by(1)-c*sin(wt)=0 Like ...

13 years ago | 0

| accepted

Load more