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

quasi 13 anni fa | 1

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

quasi 13 anni fa | 0

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

quasi 13 anni fa | 0

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

quasi 13 anni fa | 0

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

quasi 13 anni fa | 0

| accettato

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

quasi 13 anni fa | 0

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

quasi 13 anni fa | 1

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

quasi 13 anni fa | 0

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

quasi 13 anni fa | 1

| accettato

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

quasi 13 anni fa | 0

Risposto
Overlay Two Point Clouds
Use HOLD plot( …) hold on plot (…)

quasi 13 anni fa | 0

| accettato

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

quasi 13 anni fa | 0

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

quasi 13 anni fa | 0

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

quasi 13 anni fa | 0

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

quasi 13 anni fa | 0

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

quasi 13 anni fa | 0

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

quasi 13 anni fa | 0

| accettato

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

quasi 13 anni fa | 0

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

quasi 13 anni fa | 0

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

quasi 13 anni fa | 0

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

quasi 13 anni fa | 12

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

quasi 13 anni fa | 8

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

quasi 13 anni fa | 1

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

quasi 13 anni fa | 0

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

quasi 13 anni fa | 1

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

quasi 13 anni fa | 0

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

quasi 13 anni fa | 1

Risposto
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

quasi 13 anni fa | 0

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

quasi 13 anni fa | 0

| accettato

Carica altro