Answered
how can we use dynamic memory allocation in matlab?
malloc and calloc is performed by: a = zeros(1, 1e6) A free is useful under rare conditions also (huge arrays, memory exhauste...

4 years ago | 0

Answered
Solving transcendental equation numerically
You can check this using the debugger. Type this in the command window: dbstop if error Now run the code again. When Matlab st...

4 years ago | 0

| accepted

Answered
Profiler: time spend at while END statement
I interprete the displayed "times" as a a general problem of the profiler: Matlab's JIT can reorder commands and find abbreviati...

4 years ago | 1

Answered
Screen.mexw64 file missing or inaccessible on my MATLAB path
The message explains: This mex file seems to be missing or inaccessible on your Matlab path or it is dysfunctional: Screen.mexw...

4 years ago | 0

Answered
Regarding portability of Matlab going from Windows to Linux
I ran a large program (>300'000 lines of Matlab code) fluently after moving it from Windows to a Linux machine. This requires so...

4 years ago | 0

| accepted

Answered
the meaning of a sentence in command window
It means, that the optimizer did not found a valid solution. The value of the fitness functions does not vary more than the para...

4 years ago | 0

Answered
How to shade area between standard deviations in a plot?
data1 = load('mean.mat'); m = data1.mean; data2 = loadt('std.mat'); s = data2.sd; % Do not use "mean" and "std" as ...

4 years ago | 1

| accepted

Answered
How to let users enter integer, loop reenter again to them if they enter anything else
ready = false; while ~ready n = input('Enter number of patients : '); if ~isscalar(n) || n < 2 || n > 100 || abs(roun...

4 years ago | 0

Answered
How to write data to a binary file at a specific position?
% Some test data storing the rows in different files: nRow = 10; nCol = 1e6; for k = 1:nRow [fid, msg] = fopen(sprintf('...

4 years ago | 1

Answered
Read a file with textscan.
The file starts with this line: ###################################################################### This does not match the...

4 years ago | 0

Answered
I need to create a for loop that begins at 0.01 and increases by a factor of 1.1 until reaching 24.
"I need to create a for loop" This means for or while. "that begins at 0.01" x = 0.01 "and increases by a factor of 1.1" x ...

4 years ago | 0

Answered
Add a number to a region of cells bounded by nonzero numbers in a matrix
A = [0 0 0 0 0 0 0 0 0 0; 0 0 0 0 3 9 2 1 3 0; 0 0 2 4 1 0 0 0 0 0; 0 0 3 3 2 4 9 2 0 0; 0 5 1 3 0 0 4 2 0 ...

4 years ago | 0

| accepted

Answered
Is this a MATLAB bug? (Logical expression)
(x1 | x2) is TRUE, if at least one of them is not zero. If both are zero, FALSE is replied. In the next step TRUE is converted t...

4 years ago | 2

| accepted

Answered
How to speed up the code to check if randomly generated number in a certain range is a prime ?
Avoid to call isprime repeatedly. If the numbers are limited, check only once, if they are prime: m = false(1, 48593); m(prime...

4 years ago | 0

Answered
problem in showing result
Matlab evaluates an expression from left to right. So there is no difference between 610000 <= x11 <= 33683000 and (610000 <=...

4 years ago | 0

| accepted

Answered
Run another script via run parameter
The best way is to avoid scripts and to use functions instead. Scripts increase the complexity of the code, because side effects...

4 years ago | 0

Answered
Optimization of a matrix variable
By: a = z; % instead of z(N:L) ? This looks trivial, so do I oversee a detail?

4 years ago | 0

| accepted

Answered
How to reduce the decimal places if I want to save the mat file from the workspace?
There are two options: Use a MAT format with compression: -v7.3 . See: doc save Convert doubles to singles or (U)INT32/16/8 a...

4 years ago | 0

Answered
Loop through same procedure for different inputs.
cnt = 15; % centre point (s) fqn = 200; % scale factor (Hz) for t = [5, 10, 20] % time period (s) LBD = fq...

4 years ago | 0

| accepted

Answered
why will my function not take my array 'slope' as an answer. I am writing code to differentiate an equation by finding the average gradient.
If n==6, you request x(7) in: dx = x(n+1)-x(n); There is no x(7). y(n+1) must fail also. The error message is clear. There ar...

4 years ago | 0

| accepted

Answered
Convert ASCII file numbers to a date/duration
t = [500.00; 121314.15; 235500.00]; mod([floor(t / 10000), floor(t / 100), t], 100) d = duration(mod([floor(t / 10000), floor(...

4 years ago | 2

Answered
ode45,Too many output arguments error
The complete error message is (remember to include it in a question, whenever an error occurs): The Problem occurs here: fun...

4 years ago | 1

| accepted

Answered
How to shuffle rows in pairs in a 600 x 2 matrix that only contains integers?
A = [10 1; ... 30 2; ... 50 1; ... 70 8; ... 90 3; ... 10 5; ... 40 6; ... 50 2]; s =...

4 years ago | 1

| accepted

Answered
m file code sometimes loss a "end" and corruput the file on hard disc.
It is extremely unlikely, that the 3 characters "end" vanish inside a text file, while the rest of the computer runs without a c...

4 years ago | 0

| accepted

Answered
How to check for reversed pairings in columns of a matrix?
A = [1 2 5 6 0 2 3 5 6 7 1 8 0 2; ... % Value appended!!! 2 1 7 6 2 0 2 0 0 1 1 1 1 1; ... 3 5 0 1 5 8 2 0 0 2 3 0...

4 years ago | 0

| accepted

Answered
is it possible to slow down CPU to an arbitrary pace?
I do not know a tool to reduced the CPU speed freely. Even if there is such a tool, you cannot compare a modern multi-core CPU ...

4 years ago | 0

Answered
How to read and store user input as an integer.
Either: num = input(prompt); num = round(num); % to be sure or: txt = input(prompt, 's'); num = sscanf(txt, '%i', 1);

4 years ago | 0

Answered
Why do I get "no solution found" in fsolve while there is the actual value for them?
Whith the function ala() you function is not smooth. Then a local search, which considers the derivative of the function, must f...

4 years ago | 0

Answered
How can I change my plot size?
You can change the 'Position' property of the axes. If you avoid to set the axes limits to 'square' explicitly, this should work...

4 years ago | 0

Answered
Sorting a string by the use of another predetermined string order
The question is strange. Currently the best solution is: A = ["FLOATING.NET.P2" "PDSTL" "POLY1.1" "POLY1.5" "CONT.1" "ANCH.4" ....

4 years ago | 0

| accepted

Load more