how to determine the relative position of a number in a matrix
>> M = [1 0 0 0 % valid 1 0 0 1 % valid 1 0 0 -1 % valid 1 0 -1 0 % valid ...

15 days ago | 1

| accepted

Convert a vector to vector sequentially?
>> init = [1 2 3 4] >> final = [5 6 7 8] >> X = triu(ones(5,4)); >> M = init.*X + final.*~X M = 1 2 3 4 5 2...

15 days ago | 1

Loop function over multiple subfolders within one root folder?
The MATLAB documentation shows you can either obtain the names (i.e. using dir) or generate them (e.g. using sprintf): https://...

16 days ago | 0

turning date strings to overal minutes
Just use datetime, e.g.: >> C = {... '2019_12_31_17_43_31.39-Isd' '2019_12_31_17_19_36.39-Ig' '2019_12_31_16_55_41.38-Ig' '...

16 days ago | 0

| accepted

Efficient way of finding numbers from one matrix in another, not using for loops
Your code's slowness is partly due to the fact that you are expanding the output array ElementNodes on each loop iteration: this...

17 days ago | 1

| accepted

how to create new folder ?

17 days ago | 0

Check if file exists (without having the full name)

17 days ago | 0

mkdir and simulations problems

17 days ago | 1

| accepted

I have a script file which simply saves some variable into a .txt file format.But now i want that everytime i run the script,it must save .txt file with different name.Please help.
You could download my FEX submission nextname. Each time the script runs generate a new filename like this: name = nextname('hi...

17 days ago | 0

Save multiple run result of script
An alternative to using a loop: download my FEX submission nextname, which will generate the next name each time you call it. Si...

17 days ago | 1

How do I create a new folder each time I run a code?
There are two problems with your code: You are not passing nextname the path of that location, so instead of looking in the loc...

17 days ago | 0

| accepted

Submitted

Next Available Filename
Returns the next unused file or folder name. The name is created by incrementing a numbered suffix.

How determined lowest value in cell?
For some reason you want to get the number of rows but in your code you check the number of columns. Also your input to cellfun ...

18 days ago | 1

| accepted

TUTORIAL: Why Variables Should Not Be Named Dynamically (eval)
Buggy Using eval makes it really hard to track down bugs, because it obfuscates the code and disables lots of code helper tools...

18 days ago | 6

how can i create this matrix
>> [I,J] = ndgrid(1:7,1:8); >> X = I>J; >> M = (2+2*~X).*J.*X - 2.*~X.*I - X M = -2 -2 -2 -2 -2 -2 -2 -2 ...

18 days ago | 0

set difference between two cell arrays
>> A = {2,[2,3]}; >> B = {2,3}; >> [XA,XB] = ndgrid(1:numel(A),1:numel(B)); >> X = arrayfun(@(xA,xB)isequal(A{xA},B{xB}),XA,X...

19 days ago | 0

| accepted

How to say concatenate from string 2 to end?
V = ["A","B","C","D"] W = join(V(2:end),"-")

19 days ago | 2

convert string to cell
If the inputs are scalar strings use + to append them together: equation{a} = Parameters(a) + "=" + a0 + "+" + a1 + "+" + a2; ...

20 days ago | 0

| accepted

regexp: what am I missing from the documentation?
A direct interpretation of your description "assume that all name instances in a character vector test have one of two possible ...

20 days ago | 3

| accepted

how to load multiple text files in nested folder?
Probably the sprintf method does what you need: https://www.mathworks.com/help/matlab/import_export/process-a-sequence-of-files...

21 days ago | 0

| accepted

What is the meaning of ~ at fuction?
MATLAB has positional function input and output arguments. This means their purpose is determined entirely by their position whe...

22 days ago | 2

| accepted

Extracting values from a cell array into new arrays
Step 1: indexing: D = C(b(:,1)); Step 2: cellfun and an anonymous function: F = @(m,v)m(m(:,2)==v,:); Z = cellfun(F,D(:),num...

22 days ago | 0

How do I read only a specific lines from txt file and store as array?
This is easy and efficient with textscan: opt = {'HeaderLines',17,'CollectOutput',true}; fmt = repmat('%f',1,5); [fid,msg] = ...

22 days ago | 2

| accepted

How would I create a matrix from the following strings
Note that specifying a suitable format string is much more efficient than importing as character/string and then converting afte...

22 days ago | 2

extract an array from cell with its indexes
>> clstr = {[],8,[7,8],[6,8],[6,7],[6,7,8],5,4,[4,8],[4,7,8],[4,6,7],[4,6,7,8],[4,5],[4,5,8],[4,5,7]}; >> ter = [4,5]; >> id...

23 days ago | 0

| accepted

Merging Arrays in a Struct and Sorting them
A more robust solution, where v is your 2x1 structure: out = sort([v.IndividualStiffnessMatrix]) Note that your field name is ...

23 days ago | 0

How to save the several results of a program in an array?
Assuming that those means are scalar values, then a simple loop: dV = [10,20,30,40,50]; nV = numel(dV); averf6 = nan(1,nV); ...

26 days ago | 1

| accepted

Submitted

Numeric to Ordinal-String
Convert numeric values to a character array of integers with ordinal suffixes. Fully vectorized!

How can I repeat the values of an array in the same order?
>> W = [1,2,3,4,5]; >> W2 = repmat(W,1,3) W2 = 1 2 3 4 5 1 2 3 4 5 1 2 3...

28 days ago | 1

| accepted