Recursively reversing large vector efficiently
Five ways to flip a row vector. The last one, reversal_v3(), answers your question. Recursion is by two order of magnitude slowe...

11 Monate ago | 0

Accessing properties in a class
There is nothing special with the name obj, it's just a name. The assignments in the method, fun1, creates a structure (named o...

11 Monate ago | 0

Gang-of-Four Design Patterns in MATLAB
I'm not aware of any "full or partial MATLAB collection" and I've search for it more than once. Googling for "design patterns ...

11 Monate ago | 1

How to relocate (left side) the legend in plot ?
Read the documentation on legend() and notice legend(___,'Location',lcn)

11 Monate ago | 0

| accepted

Creating charts in Matlab
Yes, see the function, bar( ..., 'stacked' ). However, it lacks the 3D character of the bars.

11 Monate ago | 1

| accepted

MATLAB Answers Wish-list #5 (and bug reports)
Background: I recently put some effort into answering How to store and reuse coefficients in a for loop. My answer together wi...

11 Monate ago | 1

How to store and reuse coefficients in a for loop
Caveat: I don't fully understand your code and what I say might not be relevant to your real project. "% Can this double for lo...

11 Monate ago | 1

| accepted

check ismember for each element individually
The function arrayfun() does the trick (i.e. hides the foor-loop) a=[ 1 2 3 3 5 6 6]; b=[1 2 3 5 6]; cac = arrayfun( @(ii) fi...

11 Monate ago | 0

Is it possible to put multiple functions in one matlab file file?
"I currently have six seperate scripts [you mean functions?]" What differs between the six functions? The name of the nc-files ...

etwa ein Jahr ago | 0

When constructing an instance of class, the constructor must preserve the class of the returned object.
I don't know C++. (For some reason you added the tag "C++".) I guess you are biased by some other language. You need to look cl...

etwa ein Jahr ago | 0

How do I make this a function?
Something like this. With Matlab it's common practise to use double for all numerical variables. (Matlab has "integer in floatin...

etwa ein Jahr ago | 0

| accepted

Create table from structure - alignment
I've modified the format specifier. %% mom.a = 1; mom.b = 2; mom.veryLongName = 3; header = {'Moment'; 'Value'}; fnames = ...

etwa ein Jahr ago | 0

How to replace a number in a row vector with NaN in certain condition
abs(x(6)-x(8)) is equal to 10. Accourding to x_new, x(8) should be replaced by NaN. Thus I have use ">=". %% vec = [15 13 9 ...

etwa ein Jahr ago | 1

| accepted

Getting Windows to open a file type using a MATLAB application
An alternative that doesn't require the Matlab compiler (but requires a Matlab license to run): Create a bat-file, e.g. read_xl...

etwa ein Jahr ago | 0

How can I read a '.dat' file on MATLAB?
google says: "A file with the . dat file extension is a generic data file that stores specific information relating to the progr...

etwa ein Jahr ago | 0

How to quickly find the indecies of elements in an array?
A = [1 9 2 8 3 7 4 6 5]; B = [5 6 7]; [~,ix] = ismember( B, A )

etwa ein Jahr ago | 0

| accepted

creating a character array in which each element takes multiple characters put together
The RHS of the two assignments in the for-loop are they correct? Don't show data as images. Seven lines can be included as cod...

etwa ein Jahr ago | 2

Why is command window printing out all the code?
There is a function called echo(), which I've never used. Have you run echo on by mistake? I reproduced the behavior you see ...

etwa ein Jahr ago | 0

Extracting data using regular expression
"all the columns [...] named "Physics", "Time", "dt", "Progress", "Nonlinear Iteration" "Linear Iterations"...."Nodes After Adap...

etwa ein Jahr ago | 1

| accepted

Load .dat files from subfolders with different names
Yes to both questions. With help of the code snippets below I guess you can put together a script. sad = dir( fullfile('Folder...

etwa ein Jahr ago | 0

Index exceeds the number of array elements (1).
Here are some links on debugging in Matlab Debug a MATLAB Program Debugging in MATLAB Debugging session Debugging Approaches...

etwa ein Jahr ago | 0

Specific values in an Array
R=[]; for i=1:1:5 for y=5:1:10 eq1=i*y; %% To save the values: R=[R; i y eq1]; end end a...

etwa ein Jahr ago | 1

Auto fetch input files to process from a specified folder
"I have a lot of data files that I would like to process through my code [...] each file from a specified folder one at a time" ...

etwa ein Jahr ago | 0

| accepted

Plotting a limited number of elements
"plot the first 5" An if-statement should do that. Replace plot(jvals(i,:), vetor_momentoj(i,:), '-o'), hold all by if i <= ...

etwa ein Jahr ago | 1

| accepted

How to modify a function handle?
That's simpler than you thought %% f1 = @(y) y; f2 = @(y) f1(y)*2; %% f2(5)

etwa ein Jahr ago | 0

| accepted

Storing variables in a for loop within another
"store the variable "vetor_momentoj" [...] in terms of the indexes i and j." Something like this? I replaced the calculation of...

etwa ein Jahr ago | 0

| accepted

Calculate with initial value
There is nothing that terminates the execution of the loop when convergence is reached. Thus, the while-loop will run until the ...

etwa ein Jahr ago | 1

| accepted

How to save data from a file with text and numbers?
"load this file and save lines starting from 'Step' to 'ID Type' to another file" Including the "ID Type" block - or not ? Thi...

etwa ein Jahr ago | 0

| accepted