Answered
Finding an average matrix from each matrix in an array
Which kind of array contains the matrices? A cell array, a numerical 3D array, a struct array? The solution depends on this deta...

5 years ago | 1

Answered
How can I use funtions defined in a column vector individually?
A small modification of your code let accept RK4 vector functions also: function [t, y] = RK4(fun, t0, tN, h, y0) t = t0:h:...

5 years ago | 1

| accepted

Answered
Merging several mat files in a row order
You did not explain, how a list of the files names can be obtained. I guess, that they can be found in the same folder: Folder ...

5 years ago | 1

Answered
guidata(hObject, handles) does not save my data
How did you create the GUI? This does not look as GUIDE. How are the callbacks called? Directly as defined during the creation o...

5 years ago | 0

| accepted

Answered
Command for saving .M files ?
Name = 'file1.m' Doc = matlab.desktop.editor.findOpenDocument(Name); if Doc.Editable Doc.save; end

5 years ago | 2

Answered
convert from cell of characters to the equivalent double number
array = {'G',[]; 'E','H'; 'B','J'; 'A','C'; 'D','F'}; array(cellfun('isempty', array)) = {char('A' - 1)}; array2 = cell2mat(a...

5 years ago | 0

| accepted

Answered
Smart for loop for summing cell array matrices
Yes, this does, what you expect. Simply compare the results of both methods. This is faster and looks cleaner: for RIPETIZIONE...

5 years ago | 1

Answered
Why does resetting a 0x0 cell property value result in 0x1 cell?
If we cannot see the reset function, there is no chance, that we can guess, how the {0x1} cell is created. You could add a test...

5 years ago | 0

Answered
Convert 'str' to 'number'
str = 'P12teta4'; a = str(1); b = sscanf(str(2), '%d'); c = sscanf(str(3), '%d'); ind = find(isstrprop(str(4:end), 'digit'),...

5 years ago | 0

Answered
Help Fixing Leap Year Function
Use the standard notation and no neat accumulation of commands per line: function LeapYears condition = "yes"; while strcmp(...

5 years ago | 1

| accepted

Answered
speeding up using cellfunction and arrayfun versus for-loop
The question is not clear. Please post some code, which reproduces your measurements. There are several details in your code, ...

5 years ago | 0

| accepted

Answered
How can i make a 2D convolution with x = [1 0 2; -1 3 1; -2 4 0] and h = [1 -1; 0 2] and not use conv2? Can you please help me.
Look at the definition of the convolution again. Either the orientation of h or the submatrices of x must be changed: [h1, h2]...

5 years ago | 0

Answered
How to find inf and sup of a datum not contained in an array ?
x = randi([1, 100], 1, 30); y = 1 + rand * 99; [~, index] = min(abs(x - y)); indexBefore = max(1, index - 1); indexAfter ...

5 years ago | 0

Answered
How to put in a condition from if/ifelse statements in a fprintf string.
january21 = [74 60 54 61 54 57 49 41 37 45 45 38 42 58 55 48 55 56 55 ... 55 55 57 60 65 72 71 60 48 56 60 70]; temp = jan...

5 years ago | 0

| accepted

Answered
How can i solve this "Matrix dimensions must agree" error?
omega(:, :, i + 1) = omega(:, :, i) + 10 * x_hat2(:, i) * conj(e(i))'; This works since Matlab R2016b due to the auto-expanding...

5 years ago | 0

Answered
Why all the code in a MATLAB program are just functions
"No function code" is code written to a "script". Scripts share their workspace (the list of loclly used variables) with their c...

5 years ago | 1

| accepted

Answered
How can I vectorize the fun in Matlab with single code
Vectorize the bottleneck of the code manually. There is no automagic command, which can do this for you efficiently.

5 years ago | 0

Answered
for loop over subset - finding indices vs if-clause
It depends. How expensive is "fulfill CONDITION"? Simply try it. Implement both versions and measure the timings with tic/toc. ...

5 years ago | 1

Answered
Not enough input arguments (ideal=abs(r-D)>W/2;)
You have copied the HTML key ">" instead of of the actual character > . Then "gt" is interpreted as ">=" operator but the rig...

5 years ago | 0

Answered
Can you pass same values along a chain of multiple functions?
The CamelCase or sulkingCamelCase is a convention only, which can help to keep the overview. The Matlab code runs fine without u...

5 years ago | 2

| accepted

Answered
I have difficulty to install Matlab to my PC whose os is Windows 7
Matlab 2021a is supported for Windows 7 sp1: https://www.mathworks.com/support/requirements/matlab-system-requirements.html I...

5 years ago | 0

Answered
Which one is the correct one to calculate
R = 0; L = 30; % Some educated guesses q = rand(1, L); lambda = rand(1, L); alpha = rand; dt = rand; for j...

5 years ago | 0

| accepted

Answered
Missing figures in MATLAB script
There is this brute clearing line in the middle of your code: clear all, clc, close all Of course it clears all variables and ...

5 years ago | 2

| accepted

Answered
Trying to solve an ode using Heun's method but getting an error
Slope_left = (1+4*x)*sqrt(y) Because x is a vector, Slope_left will be a vector also. At least in the 1st iteration. In later i...

5 years ago | 0

Answered
Command use to convert expression E to numeric form
Maybe you mean the output to the command window? format short pi * 1e8 format long pi * 1e8 format long g pi * 1e8 You ha...

5 years ago | 0

Answered
Looping between two functions
Simplify your code: for i=1:hsd kas(i)=wqe(i); sak(i)=kli(i); cbb(i)=bbc(i); end does the same as: kas = w...

5 years ago | 0

Answered
How to solve this issue Variable 'X' is not fully defined on some execution paths.
Insert a definition of CONDICIONTRAMO = -1 (or NaN, or 12) either on top of the code, before the IF branchs, or in a finaly else...

5 years ago | 0

| accepted

Answered
When using "Pause on Warning/Error," is there a way to avoid breaking into built-in functions?
Matlab cannot guess in which level you want to display the call stack. So either select it manually, or use try/catch/rethrow fo...

5 years ago | 0

| accepted

Answered
Sizeof double float int etc
Version 1: w = whos('z'); nbytes = w.bytes; Version 2: function S = sizeof(X) switch class(X) case {'uint64', 'in...

5 years ago | 0

| accepted

Answered
How to deal with the structure?
Do not let arrays grow iteratively because this causes exponentially growing computing times. Example: x = []; for k = 1:1e6 ...

5 years ago | 0

| accepted

Load more