How to replace values of certain rows in a matrix?
a( [2 3], : ) = repmat( b, 2, 1 ) A bit more generally: indicesToReplace = [2 3]; a( [2 3], : ) = repmat( b, indicesToReplace...

2 years ago | 0

FFT step by step help
The lpad part is a little suspicious. If you have an odd length of signal it will not work as is. Apart from that though: xdf...

2 years ago | 1

| accepted

Index exceeds the number of array elements
[A, index] = unique (A); replaces what was in A with the result of unique (i.e. all the non-unique values removed) So indexing...

2 years ago | 0

I use code like this to position my context menu under the cursor on an axes, though if you already have the figure handle at th...

2 years ago | 0

replace duplicate value by 0 in matrix or vector
[C,ia] = unique( b ); b( setdiff( 1:numel(b), ia ) ) = 0;

2 years ago | 1

Unrecognized function or variable 'axes34_CreateFcn'.
Unless you have explicitly created one axes don't have a createFcn set by default, so I assume you must have asked it to create ...

2 years ago | 0

disp function error in matlab coder
disp is not supported by Coder. sprintf should work though.

2 years ago | 0

How to create empty matrix in matlab?
myMatrix = cell( 10 ); would create a 10x10 cell array. If all your images are the same size though you'd be better off with t...

2 years ago | 1

How can I display a specific frame in my image series ?
image10 = allImages( :, :, 10 ); images2_5 = double( allImages( :, : [2 5] ) ); image2_minusImage5 = diff( images2_5, [], 3 );...

2 years ago | 0

| accepted

extract logical locations that match array
B .* A would seem to give what you want

2 years ago | 0

| accepted

how to select the desired range of each dimension from the 3d array?
new_precipitation = precipitation( 1400:1439, 500:519, 700:900 ) would create what you ask for though it will be 1 bigger in ea...

2 years ago | 0

| accepted

Convert Z dimension to X dimension
myArray(:) will do for that kind of reshape, where myArray is obviously the array you start with.

2 years ago | 0

| accepted

Initial centroids selection - Kmeans
doc kmeans shows the idx = kmeans(X,k,Name,Value) function signature. If you look at the options for 'Name', 'Value' pairs y...

2 years ago | 0

| accepted

MATLAB Answers Wish-list #5 (and bug reports)
Has there been any further thought on changing what is considered a compulsory field for users asking a question? Title, body a...

2 years ago | 4

How to define range using a variable in xlsread?
doc sprintf can create a string out of variables, e.g. columnStr = 'B'; startRow = 50; endRow = 50; sprintf( '%s%i:EHI%i', ...

2 years ago | 0

| accepted

SOM codebook vectors output
net.IW{1} will give you the codebook vectors/weights. For example: x = simplecluster_dataset; net = selforgmap([8 8]); net ...

3 years ago | 0

| accepted

How to automatically put the asked values in function by script?
You would have to define a function that takes two arguments (or an array of inputs to add), e.g. for an example of a fixed two ...

3 years ago | 0

Dimensions of arrays being concatenated are not consistent.
Results_Values=[Amp',N',T',[velocity NaN].'];

3 years ago | 1

| accepted

Could anyone help me how to store the result together in single matrix.
Making minimal changes to your code: B=[1 2; 1 3; 2 5; 2 4; 3 5; 4 6; ...

3 years ago | 0

| accepted

How to generate random matrix from another one?
newMatrix = reshape( oldMatrix( randperm( numel( oldMatrix ) ) ), size( oldMatrix ) ); should work, though I'm sure there are n...

3 years ago | 0

Array indices must be positive integers or logical values
for i = length(Mag) doesn't make sense as this will just evaluate to a scalar. I don't see how this would be the source of you...

3 years ago | 0

| accepted

Put label in colorbar
The label object should have a position that you can edit. The rotation of 270 rather than 90 moves it inside the tick labels f...

3 years ago | 4

| accepted

Determination of data points in each cluster of K-means algorithm
accumarray( idx, 1 );

3 years ago | 1

undefined function 'isnan' for input arguments of type 'table'
Assuming data is a table, try using curley braces { } instead of parentheses ( ), i.e. y=data{:,20}; X=data{:,[17:19,21:29]}; ...

3 years ago | 1

| accepted

Transfer variables within function with different properties.
Either return it as an output argument from the previous function and pass it in as an input argument or store it as a class pro...

3 years ago | 1

| accepted

Using the function fmincon
The first argument needs to be a function handle, not a call to the function, although your function is FUNCTION so I'm not sure...

3 years ago | 0

Define function for rounding to precision
Usual scenario would be to multiply by 10^decimalPlaces, ceil and then divide by 10^decimalPlaces I would imagine. e.g. ceil( ...

3 years ago | 1

How to plot the curve?
R = B ./ ( 1 + k'/2 ); figure; plot( R ) or R = bsxfun( @rdivide, B, ( 1 + k'/2 ) ); for earlier versions of Matlab that don...

3 years ago | 0

| accepted