Answered

Find minimum difference between matrices.

Another way using histc() function (may be faster for large matrices). A = rand(5,5); %first matrix B = rand(2,3); %s...

Find minimum difference between matrices.

Another way using histc() function (may be faster for large matrices). A = rand(5,5); %first matrix B = rand(2,3); %s...

más de 8 años ago | 1

Answered

How to repeat rows of matrix?

One way: f = @(k) repmat(M(k,:), round(V(k)), 1); MM = cell2mat(arrayfun(f, (1:length(V))', 'UniformOutput', false));

How to repeat rows of matrix?

One way: f = @(k) repmat(M(k,:), round(V(k)), 1); MM = cell2mat(arrayfun(f, (1:length(V))', 'UniformOutput', false));

más de 8 años ago | 0

| accepted

Answered

Size of data points in random scatter image

This is actually a relatively straightforward process. Steps: 1. Threshold image to convert to black and white. im2bw() fu...

Size of data points in random scatter image

This is actually a relatively straightforward process. Steps: 1. Threshold image to convert to black and white. im2bw() fu...

más de 8 años ago | 0

| accepted

Answered

Comparing Vector Elements (of 2 vectors)

I think this should do what you want: Rc = mat2cell(R, 1, ones(size(R))); comp = cellfun(@(x) find(P<x,1,'last'), ...

Comparing Vector Elements (of 2 vectors)

I think this should do what you want: Rc = mat2cell(R, 1, ones(size(R))); comp = cellfun(@(x) find(P<x,1,'last'), ...

más de 8 años ago | 0

| accepted

Answered

Find consecutive values in a vector that are above a threshold

One way: s = RandStream('mcg16807','Seed',0); RandStream.setDefaultStream(s); %set seed so example is reproducible m...

Find consecutive values in a vector that are above a threshold

One way: s = RandStream('mcg16807','Seed',0); RandStream.setDefaultStream(s); %set seed so example is reproducible m...

más de 8 años ago | 6

| accepted

Answered

How to divide an arc?

If I understand your question correctly, John D'Errico's interparc ( <http://www.mathworks.com/matlabcentral/fileexchange/34874-...

How to divide an arc?

If I understand your question correctly, John D'Errico's interparc ( <http://www.mathworks.com/matlabcentral/fileexchange/34874-...

más de 8 años ago | 1

Answered

Extract Variable from Filename?

You can use strtok() or other methods, but I prefer regexp here: filename = 'sitename.yr.synth.daily.mat' %example ...

Extract Variable from Filename?

You can use strtok() or other methods, but I prefer regexp here: filename = 'sitename.yr.synth.daily.mat' %example ...

más de 8 años ago | 0

| accepted

Answered

Matlab code for system of differential equations (chemical kinetics) fitting to data

To be clear, you want to fit experimental data to a system of differential equations with some number of unknown parameters, cor...

Matlab code for system of differential equations (chemical kinetics) fitting to data

To be clear, you want to fit experimental data to a system of differential equations with some number of unknown parameters, cor...

más de 8 años ago | 3

Answered

I have matrix A, how can I add a row in matrix A with others rows of matrix A ?

b = sum(a(:,1:10:91),2)

I have matrix A, how can I add a row in matrix A with others rows of matrix A ?

b = sum(a(:,1:10:91),2)

más de 8 años ago | 2

| accepted

Answered

thermal images processing || Need help! :)

Here's an example of an approach that might work: X= imread('coins.png'); %sample indexed image BW = (X > 100); ...

thermal images processing || Need help! :)

Here's an example of an approach that might work: X= imread('coins.png'); %sample indexed image BW = (X > 100); ...

más de 8 años ago | 1

Answered

convert Vector into matrix ?

It might not be very efficient, but I think it should work: nc = 3; %number of columns in B nc = nc-1; c = 1:(length...

convert Vector into matrix ?

It might not be very efficient, but I think it should work: nc = 3; %number of columns in B nc = nc-1; c = 1:(length...

más de 8 años ago | 0

Answered

Improve Ellipse Fit around a Binary Image

To build on Image Analyst's point, you can do something like this. outline = bwmorph( isolatedBean, 'skel'); %convert ...

Improve Ellipse Fit around a Binary Image

To build on Image Analyst's point, you can do something like this. outline = bwmorph( isolatedBean, 'skel'); %convert ...

más de 8 años ago | 0

Answered

How to resample a signal by a fraction

You could use interpolation instead. Something like this: vnew = interp1( t, v, t/(1+a), 'linear'); You could use other ...

How to resample a signal by a fraction

You could use interpolation instead. Something like this: vnew = interp1( t, v, t/(1+a), 'linear'); You could use other ...

más de 8 años ago | 0

| accepted

Answered

Filling gaps in time series with Nan

One way that considers floating point errors: startValue = datenum(2013,5,17,0,0,0); %your starting observation endVa...

Filling gaps in time series with Nan

One way that considers floating point errors: startValue = datenum(2013,5,17,0,0,0); %your starting observation endVa...

más de 8 años ago | 1

Answered

How do I get regexp to read specific values in a text file?

This seems to work for me: pattern = 'Platform:\s+(\d+)'; data = regexp(indata, pattern, 'tokens'); data = cell2mat...

How do I get regexp to read specific values in a text file?

This seems to work for me: pattern = 'Platform:\s+(\d+)'; data = regexp(indata, pattern, 'tokens'); data = cell2mat...

más de 8 años ago | 1

| accepted

Answered

how to find indices on a boundary?

You can use the inpoly() function on the file exchange ( <http://www.mathworks.com/matlabcentral/fileexchange/10391-fast-points-...

how to find indices on a boundary?

You can use the inpoly() function on the file exchange ( <http://www.mathworks.com/matlabcentral/fileexchange/10391-fast-points-...

más de 8 años ago | 0

Answered

Extract non-zero elements from matrix with double precision numbers

notZeros= M(M~=0); Keep in mind that due to numerical precision, some of your matrix elements may be small but not identica...

Extract non-zero elements from matrix with double precision numbers

notZeros= M(M~=0); Keep in mind that due to numerical precision, some of your matrix elements may be small but not identica...

más de 8 años ago | 0

Answered

index of a sequence

You don't really need the loops: a=[50 150 80 200 30]; b=[60 50 150 70 200]; [d,rows]= min([a;b], [], 1); %get l...

index of a sequence

You don't really need the loops: a=[50 150 80 200 30]; b=[60 50 150 70 200]; [d,rows]= min([a;b], [], 1); %get l...

más de 8 años ago | 1

| accepted

Answered

How to a partition a data set of days into weekdays and weekends

Hi Torrey, I think this should do it: %Matrix is your 365x48 matrix %Every 4th and 5th rows are Saturday and Sunday ...

How to a partition a data set of days into weekdays and weekends

Hi Torrey, I think this should do it: %Matrix is your 365x48 matrix %Every 4th and 5th rows are Saturday and Sunday ...

más de 8 años ago | 0

Answered

Script Writes Correctly, The Graph Still Doesn't Show Up

Call hold on after your silhouette() call. 'hold on' prevents the current axes from being cleared after each plotting command. ...

Script Writes Correctly, The Graph Still Doesn't Show Up

Call hold on after your silhouette() call. 'hold on' prevents the current axes from being cleared after each plotting command. ...

más de 8 años ago | 0

| accepted

Answered

replacing components of a matrix

%your matrix is M isBetween = (M >= 2.9) & (M <= 3.2); M(isBetween) = -1

replacing components of a matrix

%your matrix is M isBetween = (M >= 2.9) & (M <= 3.2); M(isBetween) = -1

más de 8 años ago | 0

| accepted

Answered

how to calculate the area under a plot? when I use the area option, I'm not getting a satisfactory value. someone pls help me.

This isn't what the area() function does. The area function plots a filled shape below the line that is passed into it. The grap...

how to calculate the area under a plot? when I use the area option, I'm not getting a satisfactory value. someone pls help me.

This isn't what the area() function does. The area function plots a filled shape below the line that is passed into it. The grap...

más de 8 años ago | 0

Answered

How do I get both the minimum of a 2D matrix and it's indices?

minMatrix = min(matrix(:)); [row,col] = find(matrix==minMatrix);

How do I get both the minimum of a 2D matrix and it's indices?

minMatrix = min(matrix(:)); [row,col] = find(matrix==minMatrix);

más de 8 años ago | 15

Answered

How to open .dat file

Use the functional form of load, i.e. load(f)

How to open .dat file

Use the functional form of load, i.e. load(f)

más de 8 años ago | 0

| accepted

Answered

How can shape a matrix with predefined vectors?

N = [N1; N2; N3];

How can shape a matrix with predefined vectors?

N = [N1; N2; N3];

más de 8 años ago | 1

| accepted

Answered

XTick Visibility off with XTickLabel showing

set(axes2, 'TickLength', [0 0]);

XTick Visibility off with XTickLabel showing

set(axes2, 'TickLength', [0 0]);

más de 8 años ago | 1

| accepted

Answered

How to avoid for loops when generating index arrays?

It's kind of hack-y, but it gives the same output as your original posting: n=4; l = cell2mat(arrayfun(@(x) x*ones...

How to avoid for loops when generating index arrays?

It's kind of hack-y, but it gives the same output as your original posting: n=4; l = cell2mat(arrayfun(@(x) x*ones...

más de 8 años ago | 0

Answered

How can I plot 3D TENT with MATLAB?

For part (a), I would look up the documentation for the following two commands: linspace %to create your x and y domain ve...

How can I plot 3D TENT with MATLAB?

For part (a), I would look up the documentation for the following two commands: linspace %to create your x and y domain ve...

más de 8 años ago | 0

Answered

Loading ascii data file with headers

This should do it fid = fopen('path/to/your/file.txt', 'rt'); Data = textscan(fid, '%d %f %f', 'headerLines', 3, 'Collec...

Loading ascii data file with headers

This should do it fid = fopen('path/to/your/file.txt', 'rt'); Data = textscan(fid, '%d %f %f', 'headerLines', 3, 'Collec...

más de 8 años ago | 0

| accepted