Respondida
Generating a random binary matrix
Some other suggestions n = 4 ; m = 5 ; A1 = rand(n,m) < 0.5 % a logical array consuming little memory A2 = round(rand...

más de 12 años hace | 0

Respondida
An error occurs when setting an axes to current axes.
Most likely, ax2 is empty, because that axes has been deleted … Remove the semi-colon to see if this is indeed the case: a...

más de 12 años hace | 0

Respondida
Rearrange 3 small matrices to a bigger one with a certain order: taking first n-rows of each of the smaller matrices after each other
You can use some clever indexing: A1 = cumsum(ones(4,2)), A2 = A1 + 4, A3 = A1 + 8 % as above n = 2 ; % engine ...

más de 12 años hace | 0

Respondida
Insert Zeros (m -rows) in an existing Matrix every n-rows in an efficient way
But you *can* use <http://www.mathworks.com/matlabcentral/fileexchange/9984 INSERTROWS>: % data A = cumsum(ones(12,2),1)...

más de 12 años hace | 0

Respondida
how to find the length of a directory
The error is most likely to the fact there is variable called dir (or, less likely, length) in your workspace. Try this whi...

más de 12 años hace | 1

| aceptada

Respondida
sorting without moving NaNs
Use a variant of the same trick: A=[6 20; 10 10; 3 NaN; 20 66; 4 NaN; 7 12] B = flipud(sortrows(A,[2 1])) ; % descending...

más de 12 años hace | 0

| aceptada

Respondida
sorting without moving NaNs
A=[20 10 NaN 66 NaN 12] B = sort(A,'descend') A(~isnan(A)) = B(~isnan(B))

más de 12 años hace | 2

Respondida
How do I create such matrix ? (please look at the thread for further details)
help cat help vertcat help transpose help reshape After reading about those functions you should be able to do it ...

más de 12 años hace | 0

Respondida
Rewriting a value with a loop
VL = bsxfun(@plus,(1:9).',[10 20 30]) % some example data RowsToSelect = [1 3 4 7] VLnew = VL(RowsToSelect,:) ...

más de 12 años hace | 0

| aceptada

Respondida
Error in Matlab - "() Indexing must appear last in an index expression"
size(A,1) (instead of size(A)(1))

más de 12 años hace | 2

| aceptada

Respondida
Limit the state vector
help mod V = [0 1 359 361 -1] V = mod(V,360)

más de 12 años hace | 0

Respondida
How do I create such matrix ? (please look at the thread for further details)
So, the original values X4, X5 etc. are not used at all? XYZ = ceil(10*rand(4,6)) % example data RESULT = zeros(size...

más de 12 años hace | 0

| aceptada

Respondida
Running standard deviation on matrix with NaN values
function SD = nanstdrow(X) % NANSTDROW - SD per row ignoring NaNs tf = ~isnan(X) ; % non-nan values X(~tf) = 0 ; % se...

más de 12 años hace | 0

| aceptada

Respondida
For loop for correlation
Here is a method: % create some data A = 10*rand(10,4) ; k0 = 1 ; % reference column % add some columns for demo p...

más de 12 años hace | 2

Respondida
Indexing multidimensional matrices using logical arrays
A statement like *_TF = A < 0.5_* produces a logical array TF that has the same size as A. You can directly use TF to index into...

más de 12 años hace | 0

| aceptada

Respondida
How do I create a circulant matrix of shift 3 towards the left ?
It does look like a row-permuted circulant N = 31 ; dn = 3 ; A = eye(dn*N) ; % circulant ix = ones(N,d) ; % m...

más de 12 años hace | 0

Respondida
How do I create a circulant matrix of shift 3 towards the left ?
Not very flexible: A = eye(6) A = A([1 4 2 5 3 6],:) % permute as desired A(:,10) = 0 % add some zero columns

más de 12 años hace | 0

| aceptada

Respondida
how can i use multiple expression values in If-then
This should get you started: if A==1 || A == 2 disp('A is 1 or 2') ; end if B == 1 && C == 2 ...

más de 12 años hace | 0

Respondida
Cell 2 3d matrix
Use CAT and comma-separated list expansion: sz = [2 3] ; % arbitray size C = {rand(sz), ones(sz), zeros(sz)} % example o...

más de 12 años hace | 0

| aceptada

Respondida
how to convert a 2d image of ct scan/ x-rays into 3d model??
Take a look at the various tools in the image processing toolbox. As a starting point: <http://www.mathworks.com/help/matl...

más de 12 años hace | 0

Respondida
How to calculate the average without taking zeros values?
No need of a loop: A = [1 2 3 ; 10 0 30 ; 9 0 0] rowMean = sum(A,2) ./ sum(A~=0,2) Note that zeros do not contribute ...

más de 12 años hace | 12

Respondida
creating a diagonal matrix?
Like this? q = [10 20 30] ; q = q(floor(1:.5:numel(q)+.5)) % expand (there are many other ways to do this!) dia...

más de 12 años hace | 0

Respondida
how to reducing pixel size
A pixel has no dimensions … do you mean to reduce the number of pixels in an image? help imresize

más de 12 años hace | 0

Respondida
Undefined function 'findpeaks' for input arguments of type 'double'.
findpeaks is part of the signal processing toolbox in 2013b. Do you have that installed?

más de 12 años hace | 3

Respondida
Creating a polyval function
I do not really get your problem, but are you after something like this? x = -5:5 p = [3 2 4] y = p(1) for k=2...

más de 12 años hace | 0

Respondida
how to modify a text file replacing an existing string with an user-defined string
fid = fopen('infile.txt','rt') ; X = fread(fid) ; fclose(fid) ; X = char(X.') ; % replace string S1 with strin...

más de 12 años hace | 9

| aceptada

Respondida
split string into 3 letter each
In your loop code, you want to store store a string of three elements into a spot with only 1 element "word(j)". This will not f...

más de 12 años hace | 2

Respondida
HELP WITH ESTRACT SUBSTRING OF STRING
If you have version 2013b, there is a function called *strsplit* , that might work on numerical arrays (like strfind used to do)...

más de 12 años hace | 0

Respondida
vectorization of for loop
for loops are pretty fast when you use pre-allocation P_new = zeros(32,32) ; for k = 1:32 for l = 1:32 P_ne...

más de 12 años hace | 0

Respondida
Why isn't my loop running? (using strcmpi, trying to find a handle for the text)
I don't know why your loop is not running. I suggest you try some debugging. Also you change the array you're looping over insid...

más de 12 años hace | 0

| aceptada

Cargar más