Answered
Move file based on filename
https://www.mathworks.com/help/matlab/ref/movefile.html old = 'path to original folder'; new = 'path to destination folder'; ...

8 years ago | 1

| accepted

Answered
How can I use for loop to reduce the number of lines from the following code
This is MATLAB, so here is a much simpler solution without any loops: M = C1(1:399,5:11); R = mean(permute(M,[3,2,1]).*permu...

8 years ago | 0

| accepted

Answered
sscanf reader format problems
>> str = '18-11-20 22:25:00.000 BRUX XXX 2 0 0 0 4027896.395'; >> sscanf(str,'%f-%f-%f%f:%f:%f %*s %*s%f%f%f%f%f') ans = ...

8 years ago | 0

| accepted

Answered
How can I delete the rows of a matrix in matlab under a given condition
@Sky Scrapper: the standard MATLAB practice is to use any: >> A = [110,0,10,70,15;100,30,50,20,9;50,-150,95,65,7] A = 110 ...

8 years ago | 0

Answered
Command and Control vectors
>> t = [1,2,1,2,1,3]; >> kron(t-1,ones(1,5)) ans = 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 1 1 1 ...

8 years ago | 0

Answered
loading and storing specific field of many different file names of a struct
Method one: dir and a structure array: D = uigetdir(); S = dir(fullfile(D,'*.mat')); for k = 1:numel(S) S(k).import = lo...

8 years ago | 1

Answered
How to efficiently encode two values as a unique entitiy
M = [1,2,3;NaN,4,5;6,7,8]; C = M(A,B) "In addition, I also wonder if we can scale it up for A=[2;2;3;1] and B= [1;1;3;1]" ar...

8 years ago | 0

| accepted

Answered
How to loop through a matrix, one row at a time using a for loop and conditions
Simpler: M = [20,5;30,-6;40,8;50,10] X = all(M>=0,2) for k = 1:size(M,1) if X(k) M(k,:) end end

8 years ago | 0

Answered
From vector to matrix reshape every ith rows for each column
>> mat = [arr,arr,arr] mat = 1 1 1 2 2 2 3 3 3 1 1 1 2 2 2 3 3 3 1 1 1 ...

8 years ago | 0

Answered
How do I use information in mat file?
D = 'path to folder where those files are saved'; S = dir(fullfile(D,'*.mat')); N = natsortfiles({S.name}); % download from FE...

8 years ago | 0

| accepted

Answered
How to change HH:MM:SS string data to HH.MM.SS ?
>> [~,~,~,~,MN,S] = datevec([now;now-pi]) MN = 10 46 S = 22.414 28.810 >> MN+S/60 % makes mathematical sense ...

8 years ago | 0

| accepted

Answered
Change variable names in a table
You can use a cell array of names, like this: rfi.Properties.VariableNames = {'name1','name2',...} See: https://www.mathworks....

8 years ago | 3

| accepted

Answered
De-serialze char array to object
"is there a better (more elegant) way to do this?" save and load, or: https://undocumentedmatlab.com/blog/serializing-deserial...

8 years ago | 0

Answered
Please help, indexing of ND-Dimensional matrices
reshape(A,10,2,3) But it really depends on the order that you want B to have, which you did not tell us. You might need to use ...

8 years ago | 0

| accepted

Answered
how can sort the numbers according to the numbners in the first column
A general solution using accumarray: >> x = [1,2;1,3;1,2;2,4;2,6;1,7;3,8;3,9] x = 1 2 1 3 1 2 2 4 ...

8 years ago | 0

| accepted

Answered
How do I import a file containing both numbers and strings
Use textscan and set its 'TreatAsEmpty' option to 'X'. This will be much more efficient than importing and post-processing (e.g...

8 years ago | 2

| accepted

Answered
execute a script in a loop
"The script executes the inputs and gives me outputs, the outputs are crossponding to the input i.e output1, output2, output3, e...

8 years ago | 0

| accepted

Answered
check if elements in an array are equal to 0 1 or 2
"how do i check that all the elements witihin my array are equal to 0,1 or 2? " >> A = randi([0,2],4) % should pass A = 1 ...

8 years ago | 0

| accepted

Answered
Convert a string into a function of x
You can use str2func: fun = str2func(['@(x)',Sstr]); and then call it just like any other function.

8 years ago | 2

| accepted

Answered
How can I create a function which takes a matrix of characters as the input and outputs the number of specific characters within that matrix?
Two methods to count the exact sequence 'gc' on each line of the character matrix. Method one: convert to cell array, use strfi...

8 years ago | 0

Answered
Setting multiple variables to empty vectors
[flowm,flowmax,flowmin]= deal(zeros(12,1))

8 years ago | 0

| accepted

Answered
How can I create a for loop to count the number of letters in my array?
The simple MATLAB solution: >> V = 'ttgcgcatgcgcaca'; >> nnz(V=='g') ans = 4 Or to count occurances of all of the different...

8 years ago | 0

Answered
extracting row and column from a cell which contains numbers and strings
You don't need to use find, just get the second output from min: errorvals = cell2mat(mymatrix(:,11)) [minoferrorvals,idx] = ...

8 years ago | 0

Answered
datestr problem with month
If T.Date really is a datetime array, then use string to convert it to a string array. Make sure that you have set the datetime'...

8 years ago | 0

| accepted

Answered
Find number of vowels
The simpler MATLAB way: >> vc = @(s) nnz(ismember(lower(s),'aeiou')); >> vc('hello world!') ans = 3

8 years ago | 1

Answered
How i can use function handle in another function handle?
"How i can use function handle in another function handle?" Exactly like any other time you use a function, you have to call it...

8 years ago | 0

Answered
how I do it. the function is called a string is passes a numbr
function out = myfun(inp) persistent cnt if nargin==0 || isempty(cnt) cnt = 0; end cnt = cnt+1; assert(cnt<=5,'You alread...

8 years ago | 0

| accepted

Answered
How to import the image with the number.
Luckily those dates use an ISO 8601 date format, so you can simply import them sorted into character order: S = dir('*.tif') F...

8 years ago | 0

| accepted

Answered
Reference to non-existent field 'xd'. Kindly help .
The problem is related to structure C, not structure S. The fields xd and yd of structure C are defined inside while loops whos...

8 years ago | 1

| accepted

Answered
Correct indexing in a for loop - my array fills gradually?
"What am I doing wrong?" You are using a logical array as an if condition... unfortunately this is allowed, but makes no sense ...

8 years ago | 0

Load more