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

6 years ago | 1

| accepted

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

6 years ago | 1

Answered
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://...

6 years ago | 0

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

6 years ago | 0

| accepted

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

6 years ago | 1

| accepted

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

6 years ago | 1

| accepted

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

6 years ago | 0

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

6 years ago | 0

| accepted

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

6 years ago | 2

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

6 years ago | 0

| accepted

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

6 years ago | 3

| accepted

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

6 years ago | 0

| accepted

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

6 years ago | 2

| accepted

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

6 years ago | 0

Answered
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] = ...

6 years ago | 2

| accepted

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

6 years ago | 0

| accepted

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

6 years ago | 2

| accepted

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

6 years ago | 0

Answered
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); ...

6 years ago | 1

| accepted

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

6 years ago | 1

| accepted

Answered
Why isn't the progress bar in the center of the waitbar after setting the position?
The designer of the inbuilt waitbar used a fixed absolute size for the bar's axes, defined in points. Apparently they did not co...

6 years ago | 0

| accepted

Answered
Repeating Values List Problemc
>> ix = [10,11,12,12,12]; >> iy = [2,3,4,5,6]; >> [ixnew,~,idx] = unique(ix(:),'stable'); >> iynew = accumarray(idx(:),iy(:),...

6 years ago | 0

| accepted

Answered
how can I creat a matrix of all possible combinations of zero and ones across eight digits.
>> dec2bin(0:7) % try 0:255 ans = 000 001 010 011 100 101 110 111

6 years ago | 3

Answered
Exact string match to confirm the string existence in the file
>> txt = fileread('input_data.txt'); >> spl = regexp(txt,'\w+','match'); >> any(strcmp('var_ab',spl(1:2:end))) ans = 0 >> an...

6 years ago | 0

| accepted

Answered
How do I generate numbers
V = randi([100000,999999],1,100)

6 years ago | 0

Answered
how to get element of a matrix that defined as a function?
That numeric matrix is only created when the function is called, it does not exist beforehand. So you need to call the function...

6 years ago | 0

| accepted

Answered
How to run checks on all rows of structure?
"How to run checks on all rows of structure?" Your structure only has one row (and four columns): >> size(s) ans = 1 4 ...

6 years ago | 0

| accepted

Answered
How to print all loaded files in the workspace?
https://www.mathworks.com/help/matlab/import_export/process-a-sequence-of-files.html Adapting the example from the documentatio...

6 years ago | 1

| accepted

Answered
Loop different variables from workspace
The most important thing is to always load into an output variable: Q = load(...) % Q is a scalar structure where the fields o...

6 years ago | 1

| accepted

Answered
How do I find the indices of the value of my matrix?
The answer depends entirely on how you define "equals" for floating point numbers: >> [R,C] = find(abs(XX - -69.19)<1e-4) R = ...

6 years ago | 0

| accepted

Load more