Réponse apportée
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...

plus de 12 ans il y a | 0

Réponse apportée
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...

plus de 12 ans il y a | 0

Réponse apportée
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 ...

plus de 12 ans il y a | 0

Réponse apportée
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)...

plus de 12 ans il y a | 0

Réponse apportée
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...

plus de 12 ans il y a | 1

| A accepté

Réponse apportée
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...

plus de 12 ans il y a | 0

| A accepté

Réponse apportée
sorting without moving NaNs
A=[20 10 NaN 66 NaN 12] B = sort(A,'descend') A(~isnan(A)) = B(~isnan(B))

plus de 12 ans il y a | 2

Réponse apportée
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 ...

plus de 12 ans il y a | 0

Réponse apportée
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,:) ...

plus de 12 ans il y a | 0

| A accepté

Réponse apportée
Error in Matlab - "() Indexing must appear last in an index expression"
size(A,1) (instead of size(A)(1))

plus de 12 ans il y a | 2

| A accepté

Réponse apportée
Limit the state vector
help mod V = [0 1 359 361 -1] V = mod(V,360)

plus de 12 ans il y a | 0

Réponse apportée
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...

plus de 12 ans il y a | 0

| A accepté

Réponse apportée
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...

plus de 12 ans il y a | 0

| A accepté

Réponse apportée
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...

plus de 12 ans il y a | 2

Réponse apportée
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...

plus de 12 ans il y a | 0

| A accepté

Réponse apportée
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...

plus de 12 ans il y a | 0

Réponse apportée
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

plus de 12 ans il y a | 0

| A accepté

Réponse apportée
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 ...

plus de 12 ans il y a | 0

Réponse apportée
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...

plus de 12 ans il y a | 0

| A accepté

Réponse apportée
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...

plus de 12 ans il y a | 0

Réponse apportée
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 ...

plus de 12 ans il y a | 12

Réponse apportée
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...

plus de 12 ans il y a | 0

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

plus de 12 ans il y a | 0

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

plus de 12 ans il y a | 3

Réponse apportée
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...

plus de 12 ans il y a | 0

Réponse apportée
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...

plus de 12 ans il y a | 9

| A accepté

Réponse apportée
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...

plus de 12 ans il y a | 2

Réponse apportée
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)...

plus de 12 ans il y a | 0

Réponse apportée
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...

plus de 12 ans il y a | 0

Réponse apportée
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...

plus de 12 ans il y a | 0

| A accepté

Charger plus