回答済み
Passing Matrix using call by reference
Yes, using assignin and input name will do that for you function myfun(varargin) assignin('caller',inputname(1),2) ...

12年以上 前 | 1

回答済み
Passing Matrix using call by reference
Matlab does not create a copy, until it is really needed. So passing big arrays to functions uses no extra memory, except when y...

12年以上 前 | 0

回答済み
How do you find the mode of an array with ONLY ceil() floor() rand() and length() functions.
Here is a suggestion. I fail to see how ceil, floor and rand could be useful, except for creating some random data. % creat...

12年以上 前 | 0

回答済み
Single precision floating point operation
Use SINGLE to convert values to single precision x = 1.234e50 z1 = 2/x z2 = single(2/x) whos

12年以上 前 | 0

回答済み
How to solve a problem in a user friendly program?
Use a WHILE loop. This example may get you started. isOK = false ; while ~isOK A = input('Give a number: ') if...

12年以上 前 | 0

| 採用済み

回答済み
the multiplication/intersection of boolean matrices
Sure ... * A & B equals logical(A * B) * A | B equals logical(A+B) Or am I missing something … You might be interest...

12年以上 前 | 0

回答済み
Converting a the result vector from logical indexing into a matrix possible or unnescesary?
Often, you get some insight when you remove the semi-colons A = [1 2 3 4 ; 11 3 13 14 ;21 22 23 24 ; 41 3 43 44] % example ...

12年以上 前 | 1

回答済み
Suppose i have points ( 0.9, 79, 76,23, 1, 3, 4.3,89), what is the slope of the line formed by this points
help polyfit Note that points are usually defined by coordinates and not by single numbers ...

12年以上 前 | 0

回答済み
How to generate random time series with specified max-min time intervals?
Some improvements over Andrei's code minV = 0 maxV = 60 minDiff = 0.5 maxDiff = 2.0 ; N = ceil((maxV-minV) ...

12年以上 前 | 1

| 採用済み

回答済み
Identifying sequences of two or more and maintaining vector shape
x = [0 112 58 0 0 0 0 114 0 24 0 0] xx = [false x~=0 false] ix = 2:numel(x)+1 tf = ~xx(ix-1) & xx(ix) & ~xx(ix+1) ...

12年以上 前 | 0

回答済み
Overlay Two Point Clouds
Use HOLD plot( …) hold on plot (…)

12年以上 前 | 0

| 採用済み

回答済み
Max sum of array elements with condition
For consecutive elements you can use cumsum, like here: % example data M = ceil(10*rand(10,2)) % much longer in your c...

12年以上 前 | 0

回答済み
find a Nan in column of cell array and delete the row
If your cell array C has only numbers or NaNs, this will do the job C = {1 2 3 4 ; 11 12 NaN 14 ; 21 22 23 24} C(any...

12年以上 前 | 0

回答済み
how can we plot the data that we get from a for loop, just by joining the end points? I mean to say how can we form a closed figure? below is the code that i have done.
Add the first point at the end so it becomes closed. After the loop: Vxy = [vertices ; vertices(1,:)] plot(Vxy(:,1), V...

12年以上 前 | 0

回答済み
Could I trust Matlab?
Perhaps this is what you really want if abs(f(x_new)-f(x_old)) < eps … end

12年以上 前 | 0

回答済み
Linear Regression and Curve Fitting
You might be interested in the function REGRESS X = [cos(2*pi*omega*t(:)) sin(2*pi*omega*t(:))] B = regress(Y,X) If...

12年以上 前 | 0

回答済み
Ascending Sort in a cell of file names
Given your b, try this: num = cellfun(@(x) sscanf(x,'p%f-cimg.txt'),b) ; [~,sortindex] = sort(num) b(sortinde...

12年以上 前 | 0

| 採用済み

回答済み
How can I use the output of "sprintf" to read the content of a matrix
How do you get these matrices in the first place? Load them from disk? If you think of a clever way to get them into your worksp...

12年以上 前 | 0

回答済み
How to solve this error: unexpected MatLab operator
Ouch, using eval is really tricky! And does get you into all kind of problems. To solve this error you need to know the content...

12年以上 前 | 0

回答済み
Finding a character in a string?
Per definition a hashtag starts with a # sign followed by one or more letters or numbers So, quite simply, check all these th...

12年以上 前 | 0

回答済み
How to find first nonzero element/first '1' per row and set other elements to zero without loops in 3D Matrix
Something like this? % input A = round(rand(5,6,2)) % engine isOne = A == 1 ; B = isOne & cumsum(isOne,2...

12年以上 前 | 12

回答済み
Sorting data points so x are in ascending order.
Use the second output of SORT % example data X = [1 3 -4 -2] Y = [2 0 6 5] [sortedX, sortIndex] = sort(X)...

12年以上 前 | 8

回答済み
How to calculate average in a large matrix?
Here is a trick, using clever indexing with accumarray: % data A = rand(10,5) ; K = 3 ; % average of so many ro...

12年以上 前 | 1

回答済み
How to split a number into 10 different numbers?
Assuming all number should be positive integers larger than zero, this will give a random solution. Note that not all possible s...

12年以上 前 | 0

回答済み
find sum of all the entries with value 0
NNZ is the dedicated function to do this: nnz(~mat)

12年以上 前 | 1

回答済み
Any ideas on locating complex numbers in a matrix and changing their value to zero?
Take a look at *isreal*. Z(~isreal(Z)) = 0 ;

12年以上 前 | 0

回答済み
How do you replace the entry of a matrix with a string?
I suggest to use a cell array and keep the original numerical matrix for finding the elements that have to change: X1 = ran...

12年以上 前 | 1

回答済み
How do I put these 'if' statements in the same loop?
AB=randi(2,2,2)-1 C = all(AB==1,1) % per column true if both rows equal 1 C = C.' % you wanted a 2-by-1 vector

12年以上 前 | 0

回答済み
extract number out of the file title for further usage
files = dir('*.dat'); names = {files.name} ; % put the names in a cell array of strings names = strrep(names,'.dat','')...

12年以上 前 | 0

| 採用済み

さらに読み込む