Risposto
Finding equal members in a vector
V = [ 10 13 10 20 10 95 70 13]; [VU, ~, j] = unique(V) P = accumarray(j, 1:numel(V), [] ,@(x) {x}) % P{k} holds all t...

circa 8 anni fa | 0

Risposto
avoid negative index in array or matrix
Why not switch the loops, and let i start from j+1 for j=0:interval_2 for i=j+1:interval_1 % if(i-j>0) % this is ...

circa 8 anni fa | 0

Risposto
How to plot more multiple different regression lines in matlab
If you have the regression coefficients (a,b) (a sin the formula: y = ax +b), the command h = refline(a,b) will plot thi...

circa 8 anni fa | 1

| accettato

Risposto
How to circular shift a matrix for every 1 to 6 elements until its end?
Clever indexing will do the trick: A = repmat((1:18),10,1); % dummy data with 18 columns S = 6 ix = 0:size(A,2)-1...

circa 8 anni fa | 0

Risposto
Fill empty matrix with determined values
To check is a variable is empty use the function *isempty*. a = [] isempty(a) You might also want to check you if-els...

circa 8 anni fa | 0

Risposto
How can i draw two animated plots on each subplots at the same time?
Merge the for-loops! This works here because x1,y1, x2, and y2 are all the same length. There is also no need for hold on) ...

circa 8 anni fa | 3

| accettato

Risposto
To Count the reversal of a series of numbers in a column or row.
dA = diff(A) ; Nreversals = sum(diff(dA(dA~=0))<0)

circa 8 anni fa | 0

| accettato

Risposto
How do i break a string down into cell arrays containing a string?
S = 'Apples, Bananas, Dogs, Cats' C = strsplit(S, ',')

circa 8 anni fa | 1

| accettato

Risposto
Split array into sub arrays
This splits the x,y, and z values into separate blocks: x = [351;333;337;341;346;350;354;359;363;368;372;377]; y = [145;...

circa 8 anni fa | 1

Risposto
How to calculate the sum of errors for multiple variables?
An option is to scale the two errors relative to each other: ErrorT = sum(sqrt(T_exp-T_num).^2) ; ErrorX = sum(sqrt(X_ex...

circa 8 anni fa | 0

| accettato

Risposto
two for Nested Loops
Your question is a little unclear. Do you want to sum all values of the third row when the second row equals 0, equals 1, etc, s...

circa 8 anni fa | 1

Risposto
How to aggregate data based on values in a vector?
Here is one flexible approach: A = cumsum(ones(3,10),2) % a simple example, easy to check B = [2 5 6] B2 = [0 B s...

circa 8 anni fa | 0

| accettato

Risposto
Grouping elements of array according to the result of a calculation ?
Here is another, straightforward, double for-loop approach (but I do appreciate Walters cumsum solution too): V = [A B C .....

circa 8 anni fa | 0

Risposto
Creating a cell array dynamically & manipulating matrices inside the cell array
I am not sure if I understand you correctly. At some point you specify how you will read in your data and from where. This shoul...

circa 8 anni fa | 0

Risposto
How to sort the matrix rows based on a function over the rows
I have no clue what a,b and c are but I assume the function _Map(a,b,c)_ will return a vector of N elements: X = Map(a,b,c)...

circa 8 anni fa | 0

Risposto
how to do binning from two array?
Here is an easy solution: DT = [2.23, 2.83, 3.00, 3.16, 3.60, 4.00, 4.12, 4.24, 4.47, 5.00, 5.09, 5.38, 5.83, 6.00] Fre...

circa 8 anni fa | 0

Risposto
how to generate random matrix with known matrix
Indeed, as David warned, *seriously reconsider* your approach before trying the following with 15 matrices: a=[1 2 3]; b=[4...

circa 8 anni fa | 2

| accettato

Risposto
How can I restart a loop for the same iteration?
Use a while loop: k = 0 while k < N k = k + 1 ; ... do stuff if ... k = 0 ; % start again ...

circa 8 anni fa | 1

Inviato


GRIDXY
Plot horizontal / vertical grid reference lines

circa 8 anni fa | 3 download |

4.8 / 5
Thumbnail

Risposto
Vectors Must be the Same Length
Is this what you want? X = 1:50 ; Y = rand(size(X)) ; Ymean = mean(Y(:)) ; % get single value; prefered over mean(mea...

circa 8 anni fa | 0

Risposto
Sum of each row ?
Use the matlab way! Use the functions *mean*, or *sum* and *size*. Read the documentation on these functions and pay attention t...

circa 8 anni fa | 0

Risposto
Extracting numbers from cell using regex
You can use cellfun to scan every string: C = {'2/6';'78/6';'982/47';'11/6'} V = cellfun(@(c) sscanf(c,'%f/%f'), C...

circa 8 anni fa | 0

Risposto
Plotting a Gantt Chart from a Matrix
Use graphic handles to manipulate the graph: Positions=[1,2,3,4]; Gap_Duration=[0,2,5,3,5,3; 3,5,3,5,3,4; ...

circa 8 anni fa | 2

Risposto
How can I plot an animated circle?
Calculate the endpoints * x = r*cos(2*pi*f*t) * y = r*sin(2*pi*f*t) where r, is the radius, f is the frequency and t is t...

circa 8 anni fa | 0

Risposto
Modify matrix, row vector
Read the documentation and learn! :D <https://uk.mathworks.com/help/matlab/learn_matlab/array-indexing.html>

circa 8 anni fa | 0

Risposto
Reshape array of cells with different column sizes into matrix
Here is a way: T = {[1:5:21]',[2:5:22]',[3:5:23]',[4:5:24]',[5:5:20]'} m=3 n=8 [M, tf] = padcat(T{:}) M = M.' ...

circa 8 anni fa | 0

| accettato

Risposto
How to multiply N matrices without a FOR loop? (Slices of 3D array)
Here is one using recursion without a for-loop; not faster though, and somewhat mysterious, but just nice :) ... M = randi(...

circa 8 anni fa | 0

Risposto
How to make it a one line code?
Here is another but shorter two-liner using a functional programming approach for anonymous function: matrix= [1 0 -1 0.001...

circa 8 anni fa | 1

Risposto
Converting 3D data to 2D
So, you want to ignore the z, and average the values for each specific combination of (x,y)? xyzv = [1 1 1 10 ; 1 1 2 20 ; ...

circa 8 anni fa | 0

| accettato

Risposto
Clustering matrices in cells
M = {1 2 3 4} % N=4, 1-by-1 matrices for simplicity conditions = logical([1 1 0 1; 0 1 1 0]) % K = 2 G = arrayfun(@(k) M...

circa 8 anni fa | 0

Carica altro