Answered
Giving Vector Inputs in Function Handles
Adam danz hit the point alread. If you have a function with 50 or 100 inputs, this is the design problem already. Your example...

5 years ago | 2

| accepted

Answered
create a graphe with callbacks
Did you add the button already? Then use a callback: % [UNTESTED CODE] hdl.buttonH = uicontrol('Style', 'PushBotton', ... ...

5 years ago | 0

| accepted

Answered
How to avoid the warning message: "Warning: Matrix is close to singular or badly scaled. Results may be inaccurate."
The warning is important. See: https://www.mathworks.com/matlabcentral/answers/99745-why-do-i-get-warning-message-matrix-is-clos...

5 years ago | 0

Answered
How do i find the optimum variable values to maximise a Function?
y = au+bv+zw is maximal, if all u,v,w are maximal, if a,b,z are positive. For negative parameters, use the minimal allowed valu...

5 years ago | 0

Answered
File created using Matlab File Generator is empty (0 bytes)
Taken from the documentation: import mlreportgen.report.* import mlreportgen.dom.* R=Report('Simple', 'pdf') surf(peaks) ad...

5 years ago | 0

Answered
Is there an easy way to format numbers to 3 significant figures?
If "3 significant figures" mean before and after the decimal point: fprintf('%.3g', pi) fprintf('%.3g', pi * 1e9)

5 years ago | 5

Answered
Fasten the speed of assigning values to a large tensor
Avoid creating index vectors explicitly: idx1 = a1:b1; A(idx1, :) = tmp; % Slow A(a1:b1, :) = tmp; % Fa...

5 years ago | 0

Answered
How to use matrix methods
t = 1; x = 1; dt = 0.1; dx = 0.1; Value = (V(t+dt) - V(t-dt)) / (2*dt) - (V(x+dx) + V(x-dx) - 2*V(x)) / (dx^2); This is t...

5 years ago | 0

Answered
How to find this disappearing matrix using equations
A = [0,1,2; 0,1,1; 0,0,2]; A_new = [0,0,0; 0,1,0; 0,0,2]; % A_new = T * A * inv(T) % Multiply with T from the right: % ...

5 years ago | 0

Answered
how to call function based on if loop
There is no need for a loop: choice=input(' '); if choice == 1 player(); end function []= player() ... end The comm...

5 years ago | 0

Answered
How to save a variable within a for loop?
Maybe you can omit the loop: days = 13; c = max(u0(lon_useful, lat_useful, 1, 1:days), [], 4); save('fev_fim_2019.mat', '...

5 years ago | 0

Answered
an operation in progress
Some Matlab versions seems to stuck, if a disconnected network or cloud folder is included in the PATH. The question and the de...

5 years ago | 0

Answered
Why find cannot handle this very simple task?
Welcome to the world of calculations with numbers represented with limited precision. See: FAQ: Why is 0.3-0.2 ~= 0.1

5 years ago | 0

Answered
How to concatenate different mat files from different folders in a cell arrey
I guess, that the 48 folders have a common parent folder. Then see: FAQ: How to process a sequence of files BaseFolder = 'D:\Yo...

5 years ago | 0

| accepted

Answered
How to do Randi with letters
Provide a pool with valid characters and use randi() to determine the random indices: Pool = ['A':'Z', '0':'9']; Key = Pool(r...

5 years ago | 0

| accepted

Answered
Is it possible to vectorize this?
mode() handles matrices as inputs also. Only ignoring the zeros is complicated. For a comparison here the loop method: A = [1 ...

5 years ago | 1

Answered
How to list top 3
Data = readmatrix('brain_liver.csv'); Datanorm = Data .* 100 ./ max(Data, 1); S = std(Datanorm,[],2); [Max, MaxIndex] = maxk(...

5 years ago | 0

| accepted

Answered
Pyramid Table script code
a = 5; base = sqrt(3) / 2; height = 1 - 3/2; c = [-base, base, 0, -base]; d = [height, height, 1, height...

5 years ago | 0

| accepted

Answered
How can I save an image and keeping the double precision values??
You can't. Most image file formats are defined with integer types. You can write single precision data to TIFF files, but as far...

5 years ago | 0

Answered
error using ode23
dydt = B * sinh(v1 / son) .* exp(-y1.^2 ./ yon^2) ... .* exp(p1 ./ Sp) .* heaviside(v1) + ... A * sinh(v1 / s...

5 years ago | 0

Answered
How to access Variables with Incremental Names in a Loop
"with names X097_DE_time ;X098_DE_time" - this is the main problem. The solution is easy: Do not hide an index in the names of v...

5 years ago | 1

| accepted

Answered
how to solve matrix form differential equations using ODE45?
y0 = [30; 30]; tspan = [1, 1000]; [t, y] = ode45(@YourODE, tspan, y0); plot(t, y); function dy = YourODE(t, y) a1 = ...

5 years ago | 0

| accepted

Answered
FLoating point arithmetic problem - how to calculate/plot properly?
This cannot work with floating point numbers. Remember that numbers stored in double format have a limited precision. Then clacu...

5 years ago | 0

Answered
How can I generate subplots from a loop and name each one?
FigH = figure; for cv = 1:numel(C1) ax1 = subplot(2, 2, cv, 'Parent', FigH); % [EDITED] imagesc(x,y,(C1{1,cv})); ...

5 years ago | 0

| accepted

Answered
insert a column with mean of two columns in between two columns
A = [1 2 3 4; ... 1 2 3 4; ... 1 2 3 4; ... 1 2 3 4]; sA = size(A); B = zeros(sA(1), sA(2) * 2 ...

5 years ago | 0

Answered
Using a for loop to test values in an equation
Inserting too many parentheses looks confusing. for i = 1:90 cVal = (350 + (121 * 5 - 62.4 * 4 ) * cosd(i)^2 * tand(24)) / (...

5 years ago | 0

| accepted

Answered
Can anyone create an "if else while or for" from this table?
x = input('Enter a value for Resistivity: '); if x < 500 Prop = 'Highly Corrosive'; elseif x < 2000 % No need to check f...

5 years ago | 0

Answered
using function with loop
Result = zeros(1, 5); iResult = 0; for k = 1:121:605 datak = data(k:k+120); [b, n, index] = RunLength(datak < 0.1); m...

5 years ago | 1

| accepted

Answered
How to make sure a line executes only after another line is finished?
"both lines in the else loop execute at the same time" - no, this is not the way Matlab works. The lines are processed one after...

5 years ago | 0

Answered
Finding the first value in a matrix
c = [0, 0, 700; 1, 2, 3; 4, 700, 1]; d = c.'; [col, row] = find(d == 700, 1) Here the column index is replied at first, becau...

5 years ago | 0

Load more