3,100 total contributions since 2018

Communication through MATLAB is always better than arguing.

Answered

How to find position of array

Simpler without any conversions: s=[1 0 1 1 0 0 0 0 1 1 1 1]; % example data x=s~=0; Start = strfind([0,x],[0 1]) End = strf...

How to find position of array

Simpler without any conversions: s=[1 0 1 1 0 0 0 0 1 1 1 1]; % example data x=s~=0; Start = strfind([0,x],[0 1]) End = strf...

3 hours ago | 1

Answered

Unable to perform assignment because the left and right sides have a different number of elements.

No loops needed: syms sy F d g2 lsf=(g2==sy*((pi*d^2)/4)-F); mem=[61000,60000,1.5]; std=[5200,15000,0.021]; n=3...

Unable to perform assignment because the left and right sides have a different number of elements.

No loops needed: syms sy F d g2 lsf=(g2==sy*((pi*d^2)/4)-F); mem=[61000,60000,1.5]; std=[5200,15000,0.021]; n=3...

3 days ago | 0

Answered

Subscript indices must either be real positive integers or logicals.

clear all % and try again

Subscript indices must either be real positive integers or logicals.

clear all % and try again

3 days ago | 0

Answered

Check if any elements of cell array are equal ?

This method works for cells with contents of any sizes: a{1}=[1 1 0]; % example array a{2}=[0 10]; a{3}=[1 1 0]; Result = fa...

Check if any elements of cell array are equal ?

This method works for cells with contents of any sizes: a{1}=[1 1 0]; % example array a{2}=[0 10]; a{3}=[1 1 0]; Result = fa...

3 days ago | 3

Answered

Code for Multiple Matrix Multiplication

RR = cell(1,size(T,3)-1); % where T is your 3D matrix RR{1} = T(:,:,1)*T(:,:,2); for k = 2:size(T,3)-1 RR{k} = RR{k-1} * ...

Code for Multiple Matrix Multiplication

RR = cell(1,size(T,3)-1); % where T is your 3D matrix RR{1} = T(:,:,1)*T(:,:,2); for k = 2:size(T,3)-1 RR{k} = RR{k-1} * ...

3 days ago | 0

Answered

How to extract number from cell array?

cellfun(@(x) sscanf(x,'Interval: %f'),c,'un',0) % assuming follows the same pattern , turn 0 to 1 if it’s a scalar output.

How to extract number from cell array?

cellfun(@(x) sscanf(x,'Interval: %f'),c,'un',0) % assuming follows the same pattern , turn 0 to 1 if it’s a scalar output.

4 days ago | 0

Answered

Plotting graphs while solving Multiple Differential Equations using ODE45

Looks like you need to parameterize your function ( lookup doc )while you vary Wi parameter. Loop through Wi and plot the soluti...

Plotting graphs while solving Multiple Differential Equations using ODE45

Looks like you need to parameterize your function ( lookup doc )while you vary Wi parameter. Loop through Wi and plot the soluti...

4 days ago | 0

| accepted

Answered

how to combine the coordinates of points of 2 column vectors for specific width

matrix(1,:) % extracted the first coordinate , however I don’t know what you mean by label them as five perhaps text() is what...

how to combine the coordinates of points of 2 column vectors for specific width

matrix(1,:) % extracted the first coordinate , however I don’t know what you mean by label them as five perhaps text() is what...

4 days ago | 0

Answered

How to create a matrix of Matlab Functions out of a symbolic matrix?

<https://in.mathworks.com/matlabcentral/answers/466543-how-to-create-a-matrix-of-matlab-functions-out-of-a-symbolic-matrix#comme...

How to create a matrix of Matlab Functions out of a symbolic matrix?

<https://in.mathworks.com/matlabcentral/answers/466543-how-to-create-a-matrix-of-matlab-functions-out-of-a-symbolic-matrix#comme...

6 days ago | 1

| accepted

Answered

Removing NaN values in Structure

modelo2 = modelo.Val(~isnan(modelo.Val));

Removing NaN values in Structure

modelo2 = modelo.Val(~isnan(modelo.Val));

6 days ago | 0

| accepted

Answered

How to make matlab count

"Is there a way for Matlab to count how many of each number has occured." The below gives the number of counts of each unique e...

How to make matlab count

"Is there a way for Matlab to count how many of each number has occured." The below gives the number of counts of each unique e...

6 days ago | 0

Answered

Matlab: Matrix with negative numbers

No loops needed: matrix(matrix <0) = 0;

Matlab: Matrix with negative numbers

No loops needed: matrix(matrix <0) = 0;

7 days ago | 1

Answered

change last element in array by specific value matlab

Result = a; if Result(end) == specific_value % specific value is 9 for example Result(end) = 1; end

change last element in array by specific value matlab

Result = a; if Result(end) == specific_value % specific value is 9 for example Result(end) = 1; end

9 days ago | 0

| accepted

Answered

How to obtain the minimum values of an array?

Have a look at *mink()* else use *sort()* and pick the first four values if you’re using older version.

How to obtain the minimum values of an array?

Have a look at *mink()* else use *sort()* and pick the first four values if you’re using older version.

9 days ago | 1

| accepted

Answered

how does a diff operation works for relational and logical cases with arrays ?

A = [14 5 6 14 32]==14 % Split it into two lines diff(A)

how does a diff operation works for relational and logical cases with arrays ?

A = [14 5 6 14 32]==14 % Split it into two lines diff(A)

10 days ago | 0

Answered

What is an elegant way to pack and unpack an array of structures to/from a single vector?

z = struct2cell(data); x = [z{:}] data = cell2struct(z,{'r','v','m'}) % reverse

What is an elegant way to pack and unpack an array of structures to/from a single vector?

z = struct2cell(data); x = [z{:}] data = cell2struct(z,{'r','v','m'}) % reverse

10 days ago | 0

Answered

Selection of Matrix Elements without for loop

B(sub2ind(size(B),A(:,1),A(:,2)))

Selection of Matrix Elements without for loop

B(sub2ind(size(B),A(:,1),A(:,2)))

12 days ago | 1

| accepted

Answered

2D matrix to 3D

repmat(a,1,1,max(a(:))) % where a is your matrix if you have decimals in your matrix then use round function for max() to make...

2D matrix to 3D

repmat(a,1,1,max(a(:))) % where a is your matrix if you have decimals in your matrix then use round function for max() to make...

12 days ago | 0

Answered

how to sort 2 columns values based on one column

[~,idx]=sort(matrix); matrix(idx,:) % first column sorted in ascending order if vice versa use 'descend' option

how to sort 2 columns values based on one column

[~,idx]=sort(matrix); matrix(idx,:) % first column sorted in ascending order if vice versa use 'descend' option

13 days ago | 1

| accepted

Answered

How do rewrite a variable with the symbolic toolbox?

syms a b eq=a==b+3 isolate(eq,b) %or b=solve(eq,b)

How do rewrite a variable with the symbolic toolbox?

syms a b eq=a==b+3 isolate(eq,b) %or b=solve(eq,b)

13 days ago | 0

| accepted

Answered

how i can store array of string for every loop

<https://in.mathworks.com/help/matlab/import_export/process-a-sequence-of-files.html>

how i can store array of string for every loop

<https://in.mathworks.com/help/matlab/import_export/process-a-sequence-of-files.html>

13 days ago | 0

Answered

Creating vectors from rows of matrix

Subvectors = reshape(V,1,b,[])

Creating vectors from rows of matrix

Subvectors = reshape(V,1,b,[])

13 days ago | 0

| accepted

Answered

how to recognize if column is greater or row????????

if output(1) > output(2) disp('Row is greater than column') elseif output(1) < output(2) disp(' Column is great...

how to recognize if column is greater or row????????

if output(1) > output(2) disp('Row is greater than column') elseif output(1) < output(2) disp(' Column is great...

13 days ago | 0

Answered

How to access/manipulate data from cell arrays?

result{k} = x(:,2); To produce a numeric matrix you need to append with nan or zeros at the end. M=max(cellfun('prodo...

How to access/manipulate data from cell arrays?

result{k} = x(:,2); To produce a numeric matrix you need to append with nan or zeros at the end. M=max(cellfun('prodo...

14 days ago | 1

Answered

How to save the data every time i run 3 For loops?

K1 = 170000:5000:210000; B1 = 0:10:100; M1 = 1:0.05:1.2; kn = numel(K1); bn = numel(B1); mn = numel(M1); mat=zeros(kn,bn,m...

How to save the data every time i run 3 For loops?

K1 = 170000:5000:210000; B1 = 0:10:100; M1 = 1:0.05:1.2; kn = numel(K1); bn = numel(B1); mn = numel(M1); mat=zeros(kn,bn,m...

14 days ago | 0

| accepted

Answered

error saving a struct

<https://in.mathworks.com/help/matlab/ref/save.html#btppzj8-1_2> - *A* should be *'A'*

error saving a struct

<https://in.mathworks.com/help/matlab/ref/save.html#btppzj8-1_2> - *A* should be *'A'*

14 days ago | 0

| accepted