Answered
How do I find integral of a large function?
A function, which is constant with respect to t, is integrated by multiplying its value by (tf - ti). A = E * (tf - ti) Does "...

5 years ago | 0

Answered
Reversing x-axis direction for plotyy
Use the two handles replied by plotyy: t = linspace(0, 2*pi, 200); hAx = plotyy(t, sin(t), t, cos(4*t)); pause(1) set(hAx(...

5 years ago | 0

| accepted

Answered
How can I create a matrix with arrayfun
The purpose of arrayfun is: "Apply function to each element of array". This is not what you do in the nested for loops. This is...

5 years ago | 1

| accepted

Answered
Computing computational load for 2 programs
The standard method to determine the load is measuring the time, which is required to solve the problem. This can include the lo...

5 years ago | 0

| accepted

Answered
How can I create a 4-by-1 vector of twos named T?
T = [2; 2; 2; 2] % or: T = ones(4,1) + 1 % or: T = ones(4,1) * 2 % or: T = zeros(4, 1) T(:) = 2; % or: T = repmat(2, 4,...

5 years ago | 0

Answered
Look for Values in next column (max. 5 Values next)
FileData = load('example.mat'); Data = FileData.numbers; index = find(Data(:, 1)); for k = 1:numel(index) c = ...

5 years ago | 0

Answered
How can I sort valus of a field in struct?
Maybe: [~, index] = sort([R.weights]); sortedR = R(index)

5 years ago | 0

| accepted

Answered
Change the size of an icon
According to the documentation you can provide your own icon: https://www.mathworks.com/help/matlab/ref/uiconfirm.html You can...

5 years ago | 0

Answered
Why my stable point is not in [0,0]?
Your command for creating the diagram does not get any information about the X and Y coordiantes: quiver(x1s, x2s) Then it ass...

5 years ago | 0

| accepted

Answered
I've been stuck on Image Load for too long...
% cd bbdd_fase1; % No, there is no need to change the folder Folder = 'D:\Your\Data\bbdd_fase1'; % Set accordingly pngfiles ...

5 years ago | 0

Answered
How I can pause a GUI for next 20 iterations, while main program should run for every iteration.
askForWeights = 1; for k = 1:N ... if k = askForWeights soft_weight = helper_to_weight_gui('Tissue'); ...

5 years ago | 0

| accepted

Answered
Symetric matrix power optimization
Are you using this already: https://www.mathworks.com/matlabcentral/fileexchange/25782-mpower2-a-faster-matrix-power-function ...

5 years ago | 0

Answered
Matlab plots in Masters thesis
No, there is no standard format. Scientific diagrams need axes labels and tick marks.

5 years ago | 0

| accepted

Answered
How to use 'isequal' with the function 'listdlg'
The char vector need the quotes: if isequal(choiceOfRoom, 'Residential') % Or: if strcmp(choiceOfRoom, 'Residential') A nice...

5 years ago | 0

Answered
error using integral function
You do not integrate a function, but a vector: i = v.*(y*Gm+(1-y)*a.*(Gm-a*exp(b*sqrt(gp)))); Q145=integral(@(t) i,0,0.5); i ...

5 years ago | 0

Answered
Plot all if condition with for loop
figure; axes('NextPlot', 'add'); % as: hold on for s = 0:0.1:1 if s > 0 & s < 1 %avoid dividing by 0 Z2 = sqrt...

5 years ago | 1

Answered
How to search a matrix for all elements of a vector?
Start with replacing: if(~isempty(find(E(e,2:9)==NZ(n,1)))) by if any(E(e, 2:9) == NZ(n,1)) Or even better: %i need to know ...

5 years ago | 0

| accepted

Answered
How can I avoid loop for code optimization?
Start with pre-allocating the output. Letting an array grow iteratively consumes a lot of resources, because Matlab has to creat...

5 years ago | 0

Answered
Average a cell with ignoring NaN
C = {[1,2,4,6,NaN], [NaN, 2, 3, NaN]}; MC = cellfun(@(x) mean(x, 'omitnan'), C)

5 years ago | 0

| accepted

Answered
Out of memory- infinite recursion error
Posting a failing code only does not allow to fix it, because the readers do not have a chance to guess the intention of the cod...

5 years ago | 0

Answered
Clickable Plot Where non-clicked lines go transparent?
To avoid setting the bolder linewidth, simply omit the change of the linewidth: function LineSelected(ObjectH, EventData, H) ...

5 years ago | 0

Answered
Creating Dummy variables with new variable names for categorical variables
"Var1, Var2, ..." is a bad programming style, because hiding indices in the names of the variables makes it hard, to access them...

5 years ago | 0

Answered
How to repeat a command until a condition is met?
Omit expressions like: Df = Df; This is confusing only. As far as I understand, you want a loop over this piece of the code: ...

5 years ago | 1

| accepted

Answered
Versions of Euler Methods
You provide the time span and y0 as inputs already: y = forwardEuler(func, t, y0) Inside the functions, you redefine these inp...

5 years ago | 0

| accepted

Answered
How to change the y-axis values to start at 0 and not become negative?
It is not clear, what you are asking for. You can limit the Y axis by: ylim([0, 1.7]) This would crop almost all points from...

5 years ago | 0

| accepted

Answered
Encoding Gray scal image
What is the type of the variable img? The documentation of encode() mentions, that the 1st input must by a double. So try: enco...

5 years ago | 0

| accepted

Answered
Matlab code for Eratosthenes
The code works fine and replies the correct values for: [], 1, 2, 3, 10, 100, 200 Maybe inputs like NaN or vectors should be c...

5 years ago | 0

| accepted

Answered
what is wrong with my code?
conc=(1./sqrt(4*pi*D*t)*exp.(-1*((x-v*t).^2./4*D))); % ^ This is interpreted as "exp" beeing a struc...

5 years ago | 0

| accepted

Answered
In an assignment A(:) = B, the number of elements in A and B must be the same. Error in (line 9) y(m)= H(:,df)
I H is a matrix, the right hand side H(:,df) contains multiple rows, but y(m) is a scalar. Are you sure, that dt==5 in all case...

5 years ago | 0

Answered
Command "for" and "while"
Start with the smallest possible problem to understand, what the loops do. for k = 1:5 disp(k) end Please run this in you...

5 years ago | 1

| accepted

Load more