Answered
How to get line number in a text file with a specific word
No loops needed: A = regexp(fileread('fruit.txt'),'\n','split'); whichline = find(contains(A,'apple'))

7 years ago | 3

| accepted

Answered
counting the number of times a number appears next to the same one in a row?
Simpler: nnz(~diff(vector)) Note: Taking into account that we only deal with integers.

7 years ago | 1

Answered
How to turn an 1x1x3 array to a 1x3 vector?
reshape(array,1,[]) % or squeeze() transposed

7 years ago | 1

| accepted

Answered
The length of the array of cells
cellfun('prodofsize',yourcellarray)

7 years ago | 0

Answered
Set values in a matrix to zero
data=[data;zeros(43,1)] % where data is of size 957 X 1

7 years ago | 2

| accepted

Answered
Second Order Differential Equation
<https://in.mathworks.com/help/matlab/ordinary-differential-equations.html> - there are plenty of examples there , you were so c...

7 years ago | 1

| accepted

Answered
Access matrix location on one matrix with the data location on another matrix
Probably you want: idx = setdiff(1:numel(A),B); A(idx) = 0;

7 years ago | 1

Answered
Using for loop to count how many times a content appears in a cell array?
T=cell2table(arr); Wanted = sortrows(varfun(@sum,T,'GroupingVariables','arr',... 'OutputFormat','table'),2,'descend') %...

7 years ago | 1

| accepted

Answered
How to find values for corresponding start and end positons
Getting the start and positions , i believe you know it from the previous question, so don‘t waste time using a loop. bit1 =[.....

7 years ago | 0

Answered
How to add equation to function
Note: the following can be done trivially without a loop by vectorisation. t = 0:2:100; h=zeros(size(t)); for k=1:numel(t); ...

7 years ago | 1

| accepted

Answered
Extracting values from sym matrix solutions
m.Nv11 % would give you the value , also use double() to get the result in decimal form

7 years ago | 0

| accepted

Answered
Matrix Indexing with respect to sum of matrix raws
1) Sum A with respect to rows. 2) Use sort() for sum of rows and collect the second output of it. 3) Use the second output...

7 years ago | 1

| accepted

Answered
Wrong output when using random numbers
./ % this is why? see Array vs. Matlab operations [Google it]

7 years ago | 1

| accepted

Answered
Remove rows that contain NaN
B=A; B(any(isnan(B),2),:)=[]

7 years ago | 1

Answered
Leave out dot notation in table variables
I don’t know why it’s hard for you to use "D." , see <https://in.mathworks.com/help/matlab/matlab_prog/access-data-in-a-table.ht...

7 years ago | 0

Answered
how do you get the max y value in an fplot?
h = fplot(...); MAX = max(h.YData)

7 years ago | 0

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

7 years ago | 2

Answered
converting all array elements into positive elements
A = abs(A)

7 years ago | 0

| accepted

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

7 years ago | 0

Answered
Subscript indices must either be real positive integers or logicals.
clear all % and try again

7 years ago | 1

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

7 years 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} * ...

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

7 years ago | 1

| accepted

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

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

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

7 years ago | 1

| accepted

Answered
Removing NaN values in Structure
modelo2 = modelo.Val(~isnan(modelo.Val));

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

7 years ago | 0

| accepted

Answered
Matlab: Matrix with negative numbers
No loops needed: matrix(matrix <0) = 0;

7 years ago | 4

| accepted

Answered
Need a piece of code to
B = num2cell(A,2).'

7 years ago | 0

Load more