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

plus de 12 ans il y a | 1

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

plus de 12 ans il y a | 0

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

plus de 12 ans il y a | 0

Réponse apportée
Single precision floating point operation
Use SINGLE to convert values to single precision x = 1.234e50 z1 = 2/x z2 = single(2/x) whos

plus de 12 ans il y a | 0

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

plus de 12 ans il y a | 0

| A accepté

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

plus de 12 ans il y a | 0

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

plus de 12 ans il y a | 1

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

plus de 12 ans il y a | 0

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

plus de 12 ans il y a | 1

| A accepté

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

plus de 12 ans il y a | 0

Réponse apportée
Overlay Two Point Clouds
Use HOLD plot( …) hold on plot (…)

plus de 12 ans il y a | 0

| A accepté

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

plus de 12 ans il y a | 0

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

plus de 12 ans il y a | 0

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

plus de 12 ans il y a | 0

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

plus de 12 ans il y a | 0

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

plus de 12 ans il y a | 0

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

plus de 12 ans il y a | 0

| A accepté

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

plus de 12 ans il y a | 0

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

plus de 12 ans il y a | 0

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

plus de 12 ans il y a | 0

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

plus de 12 ans il y a | 12

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

plus de 12 ans il y a | 8

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

plus de 12 ans il y a | 1

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

plus de 12 ans il y a | 0

Réponse apportée
find sum of all the entries with value 0
NNZ is the dedicated function to do this: nnz(~mat)

plus de 12 ans il y a | 1

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

plus de 12 ans il y a | 0

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

plus de 12 ans il y a | 1

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

plus de 12 ans il y a | 0

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

plus de 12 ans il y a | 0

| A accepté

Charger plus