Answered
Extracting elements of a matrix in the first row and even columns
B(1,2:2:end) As the documentation clearly explains, the first position is for rows, the second for columns, the third for p...

9 years ago | 0

| accepted

Answered
Getting error while loading .mat file from many directory
Your indexing is incorrect, and you need another loop. Basically you are looping over the directories, but then you try to us...

9 years ago | 0

Answered
How do I read data after a specific string?
opt = {'Delimiter',','}; fmt = repmat('%f',1,5); C = {}; fid = fopen('test.txt','rt'); while ~feof(fid) str...

9 years ago | 1

| accepted

Answered
Create a matrix depending on values in another one
Your code does not make good use of MATLAB. In particular you make your own life much harder by splitting the data up into lots ...

9 years ago | 0

Answered
Why does this function handle not take the inputs?
The problem has nothing to do with your function handle. It is (exactly as the error message states) solely because the way you ...

9 years ago | 0

| accepted

Answered
Removing lowest value in each line from a matrix
Three lines: >> A = [0,7,7,4;-3,4,10,12;10,12,12,4]; >> B = A.'; >> B(sub2ind(size(B),idx,1:size(B,2))) = []; >> B...

9 years ago | 0

Answered
Sum function with letters
Where |C| is a cell array of strings: nnz(strcmp(C,'AIR 6'))

9 years ago | 0

Answered
How do I export an array of character into an txt file with each string separated with a new line?
If you have a cell array of strings |C|, and you want to print each string on its own line in the file, then you can do this: ...

9 years ago | 1

| accepted

Answered
Write a MATLAB script that can be used to nd the smallest number N for which the sum of the integers 1 through N is a 3 digit number.
The brute force method: N = 0; S = 0; while S<100 N = N+1; S = S+N; end

9 years ago | 0

Answered
split special merged text and number in text file
Using <http://www.mathworks.com/help/matlab/ref/textscan.html |textscan|>, <https://www.mathworks.com/help/matlab/ref/fgetl.html...

9 years ago | 0

| accepted

Answered
access the row and col of a matrix
>> N = 6; % your input >> [col,row] = ind2sub(size(A),N) col = 3 row = 2 >> val = A(row,col) val = 16

9 years ago | 2

| accepted

Answered
How do I find a streak of numbers in a range?
1. To detect runs of identical numbers: >> V = [0,1,2,3,3,3,3,4,5,5,5,5,6,7,7]; >> D = diff([false,diff(V)==0,false]); ...

9 years ago | 0

| accepted

Answered
How can i input a value and then determine it if this value is similar to one of my matrix?
You should use the |'s'| option with |input|: A = [1,2;3,4]; N = str2double(input('Enter Any Number : ','s')); if any...

9 years ago | 1

| accepted

Answered
Generating Array from nested loops
Download <https://www.mathworks.com/matlabcentral/fileexchange/23080-combinations |combinations|> or <https://www.mathworks.com/...

9 years ago | 0

| accepted

Answered
Find multiple strings within another string
One solution: wrap it all up in another |cellfun|: >> C = {'A','B','xxxa_13x','xxa_14x','C','a_13'}; >> TEST = {'a_13','...

9 years ago | 3

| accepted

Answered
Better way to grouping condition (wind compass)
>> vec = randi(360,10,1) vec = 82 305 126 44 327 232 160 163 217 219 >> C = {'...

9 years ago | 0

| accepted

Answered
Row-wise multiplication of a matrix while setting the rest of the matrix to zero
N = 5; M = rand(N,3); C = cell(N,1); for k = 1:N M_new = zeros(size(M)); M_new(k,:) = M(k,:); C{...

9 years ago | 1

Answered
how to write this function
>> idx = A>1 & A<4 & B>1 & B<3 & C>1 & C<4; >> min(obj(idx)) ans = 0.1

9 years ago | 0

Answered
Interpolating within time series
>> idx = ~isnan(A); >> interp1(find(idx),A(idx),(1:numel(A))') ans = 1438.6 1446.5 1436.7 ...

9 years ago | 0

| accepted

Answered
Is there a way to get the last thing calculated in a recursive function to be outputted instead of instead of it outputting the first thing calculated.
Taking a stab in the dark here, but reversing the order might help you: says = [say;says]

9 years ago | 0

Answered
Count common elements of two vectors, including repeats
*Edited* using all examples in comments or the original question. >> a = [9,8,7,8,6]; b = [8,9,9,6,8]; >> idx = bsxfun(@...

9 years ago | 2

Answered
what are they different file?
Some beginners think that they are the same, but they are not: the top one is a *script*, the bottom one is a *function*: <ht...

9 years ago | 0

| accepted

Answered
How to replace the diagonal elements of a matrix with 0 fro avoiding self loops?
Method one: indexing: M(1:1+size(M,1):end) = 0 Method two: |eye|: M.*~eye(size(M))

9 years ago | 7

Answered
I am running an Ff statement and i Keep getting the error Matrix dimensions must agree... Help?
*Method one: use <https://www.mathworks.com/help/matlab/ref/strcmpi.html |strcmpi|>:* if strcmpi(C,'Max') ... else...

9 years ago | 0

Answered
how to find files in a directory with a list of strings froma a matrix
Have a look at the output of this operation: >> myFolder = 'C:\Users\Desktop\Jar'; >> filePattern = fullfile(myFolder, '...

9 years ago | 1

| accepted

Answered
How do you add elements in a matrix (single column, multiple rows) and output to another matrix?
Use <https://www.mathworks.com/help/matlab/ref/diff.html |diff|>: >> [A(1);diff(A)] ans = 1 1 1

9 years ago | 1

| accepted

Answered
How to index a matrix in matlab
*Array A* >> [U,X,Y] = unique(I(:,1)); >> [~,X] = sort(X); >> [~,X] = sort(X); >> fun = @(v){cumsum(v==0)+(v(1)==1...

9 years ago | 0

| accepted

Answered
How to add a string to a filename while saving plots
Use |sprintf| and |fullfile|. You will find a complete explanation here: <https://www.mathworks.com/matlabcentral/answers/574...

9 years ago | 0

| accepted

Answered
How to increase marker size in scatter plot?
According to the <https://www.mathworks.com/help/matlab/ref/scatter.html |scatter|> documentation, like this: scatter(X,Y,2...

9 years ago | 21

| accepted

Load more