Risposto
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...

quasi 13 anni fa | 0

Risposto
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...

quasi 13 anni fa | 0

Risposto
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 ...

quasi 13 anni fa | 0

Risposto
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)...

quasi 13 anni fa | 0

Risposto
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...

quasi 13 anni fa | 1

| accettato

Risposto
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...

quasi 13 anni fa | 0

| accettato

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

quasi 13 anni fa | 2

Risposto
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 ...

quasi 13 anni fa | 0

Risposto
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,:) ...

quasi 13 anni fa | 0

| accettato

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

quasi 13 anni fa | 2

| accettato

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

quasi 13 anni fa | 0

Risposto
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...

quasi 13 anni fa | 0

| accettato

Risposto
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...

quasi 13 anni fa | 0

| accettato

Risposto
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...

quasi 13 anni fa | 2

Risposto
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...

quasi 13 anni fa | 0

| accettato

Risposto
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...

quasi 13 anni fa | 0

Risposto
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

quasi 13 anni fa | 0

| accettato

Risposto
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 ...

quasi 13 anni fa | 0

Risposto
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...

quasi 13 anni fa | 0

| accettato

Risposto
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...

quasi 13 anni fa | 0

Risposto
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 ...

quasi 13 anni fa | 12

Risposto
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...

quasi 13 anni fa | 0

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

quasi 13 anni fa | 0

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

quasi 13 anni fa | 3

Risposto
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...

quasi 13 anni fa | 0

Risposto
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...

quasi 13 anni fa | 9

| accettato

Risposto
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...

quasi 13 anni fa | 2

Risposto
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)...

quasi 13 anni fa | 0

Risposto
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...

quasi 13 anni fa | 0

Risposto
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...

quasi 13 anni fa | 0

| accettato

Carica altro