回答済み
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...

12年以上 前 | 0

回答済み
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...

12年以上 前 | 0

回答済み
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 ...

12年以上 前 | 0

回答済み
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)...

12年以上 前 | 0

回答済み
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...

12年以上 前 | 1

| 採用済み

回答済み
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...

12年以上 前 | 0

| 採用済み

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

12年以上 前 | 2

回答済み
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 ...

12年以上 前 | 0

回答済み
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,:) ...

12年以上 前 | 0

| 採用済み

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

12年以上 前 | 2

| 採用済み

回答済み
Limit the state vector
help mod V = [0 1 359 361 -1] V = mod(V,360)

12年以上 前 | 0

回答済み
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...

12年以上 前 | 0

| 採用済み

回答済み
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...

12年以上 前 | 0

| 採用済み

回答済み
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...

12年以上 前 | 2

回答済み
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...

12年以上 前 | 0

| 採用済み

回答済み
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...

12年以上 前 | 0

回答済み
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

12年以上 前 | 0

| 採用済み

回答済み
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 ...

12年以上 前 | 0

回答済み
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...

12年以上 前 | 0

| 採用済み

回答済み
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...

12年以上 前 | 0

回答済み
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 ...

12年以上 前 | 12

回答済み
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...

12年以上 前 | 0

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

12年以上 前 | 0

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

12年以上 前 | 3

回答済み
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...

12年以上 前 | 0

回答済み
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...

12年以上 前 | 9

| 採用済み

回答済み
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...

12年以上 前 | 2

回答済み
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)...

12年以上 前 | 0

回答済み
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...

12年以上 前 | 0

回答済み
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...

12年以上 前 | 0

| 採用済み

さらに読み込む