Answered
Error using interp1>reshapeAndSortXandV (line 424) X and V must be of the same length.
Assuming that meas.acc.data and meas.acc.time are vectors with the same number of elements, then diff on the data vector will re...

7 years ago | 1

| accepted

Answered
Combine strings and doubles and export to .txt
You can do this quite easily without any loops: C1 = {'Node coordinates and Elements','Coordinates'}; C2 = {'End Coordinates',...

7 years ago | 0

| accepted

Answered
How to load in .m files in a sequence to Matlab?
"The problem is that I cannot load in all .m files at once..." Your question is confusing: .m files contain code (and in genera...

7 years ago | 1

| accepted

Answered
Represent results in vector format.
>> A = 1:10 A = 1 2 3 4 5 6 7 8 9 10 >> B = [1,25,31,41,11,61,7,81,31,11;81,3,71,31,31,6,11,8,6...

7 years ago | 1

| accepted

Answered
Is there a way to avoid repeating time-consuming calculations from odefun in the events function?
"Is there a way to do the time-consuming calculations only once at each time step?" Not really, because numeric ODE solvers do ...

7 years ago | 0

| accepted

Answered
Numerical cell value changes to random symbols when using strcat - help needed
They are not random characters at all, they are in fact exactly the characters with exactly those character codes that you speci...

7 years ago | 0

| accepted

Answered
Fibonacci sequence for loop
Your while loop does not exit when you probably think it should... Actually you will get the correct answer for m=3, 5, 8, 13, ...

7 years ago | 1

| accepted

Answered
Dir on UNIX does not return .folder subfield
This has nothing to do with Unix vs. Windows OS. The feature of recursive folder searching and returning the folder was introduc...

7 years ago | 0

| accepted

Answered
Reshape a 3D matrix
Rather than using meshgrid it would be simpler to use ndgrid: >> x = [1 2 3]; >> y = [4 5 6]; >> z = [7 8 9]; >> A = randi(9...

7 years ago | 0

Answered
How to recognize it is uppercase ,lowercase , or other sign ?
Your logic is incorrect, you should be using &&, not || Also you are comparing against strings of the character values, whereas...

7 years ago | 1

| accepted

Answered
Rearrange an array based on another array
General solution: >> [~,idx] = ismember(SP,SPI); >> V = VI(idx) V = 10 10 20 10 15 20 5 10 15 15 5 ...

7 years ago | 0

| accepted

Answered
Create a new array from an intersection of two previous arrays
>> A = [1 1 1 1 4 4 4 4 6 6 6 6 6 6]; >> B = [2 2 2 2 2 2 2 2 2 2 7 7 7 7 7 7 7 7 8 8 8 8 9 9 9 9]; >> N = min(numel(A),numel(...

7 years ago | 0

| accepted

Answered
Move on to next iteration when condition is satisfied, specifically when using functions
Adding return does not skip to the start of the next loop iteration, it just exits the function. But you can easily return NaNs...

7 years ago | 0

| accepted

Answered
How to evaluate function with two variables
>> t = 0:0.1:0.5 t = 0.00000 0.10000 0.20000 0.30000 0.40000 0.50000 >> x = (0.2:0.2:0.8).' x = 0.2...

7 years ago | 0

| accepted

Answered
Obtain lines of a matrix according to its position.
All you need is some very basic indexing: B = A([2,4],:) Very basic MATLAB concepts, like how to use indexing, are explained i...

7 years ago | 1

| accepted

Answered
Find empty cells in 3D cell?
The simple MATLAB solution is to use ind2sub. First lets create some fake data: >> A = repmat({NaN},12,125,1216); >> A(5,23,[2...

7 years ago | 3

Answered
Find Structure Field using a string and modify content of data under this field
You can use dynamic fieldnames: https://www.mathworks.com/help/matlab/matlab_prog/generate-field-names-from-variables.html fld...

7 years ago | 0

| accepted

Answered
question about indexing of logic matrix
Your mistake is on this line: A=rand(20,3); You correctly wrote that "hel.faces is a m*3 matrix", but you seem to have missed ...

7 years ago | 0

| accepted

Answered
Help using contourc without meshable x-y data
Interestingly contour does not directly call contourc anywhere, instead it passes its input arguments to a contourgroup construc...

7 years ago | 2

| accepted

Answered
decimal to binary conversion of an array
Cell array of character vectors: >> a = [102,2,3,201,8,9]; >> c = arrayfun(@dec2bin,a,'uni',0); >> c{:} ans = 1100110 ans =...

7 years ago | 2

| accepted

Answered
Datetime 'convertfrom' forcing dates to be Jan2019
Your code and question do not seem to be particularly related to your uploaded data, or show some signs of confusion. For exampl...

7 years ago | 2

| accepted

Answered
Read text file - ignoring lines starting with specific character.
nmc = 4; % number of columns in file fmt = repmat('%f',1,nmc); opt = {'HeaderLines',3, 'CollectOutput',true, 'MultipleDelimsAs...

7 years ago | 0

Answered
Evaluate string as structure
The most important thing is to always load into an output variable, then your task is easy: N = 'structure_name'; S = load(N);...

7 years ago | 0

| accepted

Answered
How add multiple variables from one mat files into common mat file in loop ?
The solution is really very simple, you do not need to waste time with loops or dynamic fieldnames. First lets create two examp...

7 years ago | 0

Answered
Find values and positions of a matrix referring to another matrix
This is MATLAB, so you should learn how to efficiently solve tasks like this without loops: >> A = [2,4,7]; >> B = [3,4,6;1,5,...

7 years ago | 1

Answered
How do I take a matlab code file from the internet and use it in matlab
"... and actually import it to matlab?" MATLAB does not require code to be "imported". MATLAB automatically detects all code on...

7 years ago | 0

Answered
How to sum over each n-th element in an array ?
Just use reshape: >> b = sum(reshape(a,1001,[]),2); and checking the output: >> b(1) ans = -6343.8 >> sum(a(1:1001:end)) a...

7 years ago | 0

| accepted

Answered
Plotting values from a set of nested if-else statements in while loop nested in a for loop
An improved version of your script, without the poor practices shown in Jyotsna Talluri's answer: V = 1:1000; N = numel(V); L...

7 years ago | 0

Answered
sorting alphabetically with sortrows: underscore handled differently than in windows
If you actually want to sort filenames into alphanumeric order, then one option is to download my FEX submission natsortfiles: ...

7 years ago | 0

| accepted

Answered
Regular expressions with regexp.
>> str = '20070101'; >> rgx = '(?<year>\d{4})(?<month>\d{2})(?<day>\d{2})'; >> out = regexp(str,rgx,'names') out = yea...

7 years ago | 0

| accepted

Load more