Answered

Line plot not showing up in for loop iteration

What exactly is trhe problem with your code? Maybe all you need is to insert a drawnow command after the plotting? By the way,...

Line plot not showing up in for loop iteration

What exactly is trhe problem with your code? Maybe all you need is to insert a drawnow command after the plotting? By the way,...

23 días ago | 0

Answered

Printing the entire array row in Matlab

a = [12,3,4,5]; b = [4,5,12,3]; fprintf('a: [%s]\n', join(string(a), ',')); fprintf('b: [%s]\n', join(string(b), ','));

Printing the entire array row in Matlab

a = [12,3,4,5]; b = [4,5,12,3]; fprintf('a: [%s]\n', join(string(a), ',')); fprintf('b: [%s]\n', join(string(b), ','));

23 días ago | 1

Answered

how I create improved lorenz code

The test contains cos(dt), but your code only cos(t).

how I create improved lorenz code

The test contains cos(dt), but your code only cos(t).

23 días ago | 0

| accepted

Answered

Unrecognized function or variable 'setupgraph'

You have mentiones the source of the dijkstra function in your other thread: https://www.mathworks.com/matlabcentral/fileexchang...

Unrecognized function or variable 'setupgraph'

You have mentiones the source of the dijkstra function in your other thread: https://www.mathworks.com/matlabcentral/fileexchang...

23 días ago | 0

| accepted

Answered

find if one number is member of a column ,of cell array, that contains cell entries and if it is member, in which row, it appears

Simplify the data representation at first: for k = 1:size(C, 1) C{k, 5} = [C{k, 5}{:}]; end Then the searching is easy: ...

find if one number is member of a column ,of cell array, that contains cell entries and if it is member, in which row, it appears

Simplify the data representation at first: for k = 1:size(C, 1) C{k, 5} = [C{k, 5}{:}]; end Then the searching is easy: ...

23 días ago | 0

| accepted

Answered

function handle specify in matlabfcn function

According to the documentation doc matlabfcn : =matlabfcn("quadgk(@(x) x.^2)", M3, M4)

function handle specify in matlabfcn function

According to the documentation doc matlabfcn : =matlabfcn("quadgk(@(x) x.^2)", M3, M4)

23 días ago | 0

Answered

Define matrix function to output matrix

A = rand(3); fumn(A, @sqrt) fumn(A, @(x) 1 ./ x) fumn(A, @(x) exp(-x)) function f = fumn(A, fcn) f = fcn(A); end

Define matrix function to output matrix

A = rand(3); fumn(A, @sqrt) fumn(A, @(x) 1 ./ x) fumn(A, @(x) exp(-x)) function f = fumn(A, fcn) f = fcn(A); end

23 días ago | 0

Answered

Reducing the running time of a for loop iterating through cells

Is C pre-allocated? Why do you use square brackets? This is the concatenation operator in Matlab. As far as I understand the us...

Reducing the running time of a for loop iterating through cells

Is C pre-allocated? Why do you use square brackets? This is the concatenation operator in Matlab. As far as I understand the us...

23 días ago | 0

Answered

why in this function they use empty square brackets?

A(i,:) = []; This deletes the i.th row of the matrix A. Example: A = [1,2,3; 4,5,6; 7,8,9]; A(1, :) = [] % A = [4,5,6; 7,...

why in this function they use empty square brackets?

A(i,:) = []; This deletes the i.th row of the matrix A. Example: A = [1,2,3; 4,5,6; 7,8,9]; A(1, :) = [] % A = [4,5,6; 7,...

24 días ago | 2

Answered

Open to feedback for my code

[] is Matlab's operator for a concatenation. [0.05] concatenates the numnbre 0.05 with nothing, therefore this is a waste of tim...

Open to feedback for my code

[] is Matlab's operator for a concatenation. [0.05] concatenates the numnbre 0.05 with nothing, therefore this is a waste of tim...

24 días ago | 0

| accepted

Answered

Help with a loop that computes at each step

hs = [0.05, 0.05/2, 0.05/4, 0.05/8, 1/1000]; for k = 1:numel(hs) h = hs(k); N = totalDuration / h; % ??? y = y...

Help with a loop that computes at each step

hs = [0.05, 0.05/2, 0.05/4, 0.05/8, 1/1000]; for k = 1:numel(hs) h = hs(k); N = totalDuration / h; % ??? y = y...

24 días ago | 0

| accepted

Answered

How to call functions from inside an if statement only once?

I'm not sure if I understand you correctly, but maybe: for tt = 2: 50 ... if tt > 2 || M(tt) >= 0.3 * N [G_dmg, ~] =...

How to call functions from inside an if statement only once?

I'm not sure if I understand you correctly, but maybe: for tt = 2: 50 ... if tt > 2 || M(tt) >= 0.3 * N [G_dmg, ~] =...

24 días ago | 0

Answered

change in xlrange of xlsread while sing loop

Why do you want to import ranges at all? Import the complete file as a matrix or table and filter out the needed values by somet...

change in xlrange of xlsread while sing loop

Why do you want to import ranges at all? Import the complete file as a matrix or table and filter out the needed values by somet...

24 días ago | 0

Answered

Invalid expression. When calling a function or indexing a variable

You cannot use constants in the definition of the inputs of a function: function [e L] = dijkstra(datos,1,12) % ...

Invalid expression. When calling a function or indexing a variable

You cannot use constants in the definition of the inputs of a function: function [e L] = dijkstra(datos,1,12) % ...

24 días ago | 1

Answered

How to trace the end point of my vector without losing other plots?

Do not delete obejcts and draw new ones, but keep the obejcts and modify the coordinates. If nothing is deleted, it is easy to k...

How to trace the end point of my vector without losing other plots?

Do not delete obejcts and draw new ones, but keep the obejcts and modify the coordinates. If nothing is deleted, it is easy to k...

25 días ago | 0

Answered

Error using mex Access denied; check that you have permissions to access.

Without Admin privilges you cannot write to the Programs folder - and this is a good idea. Copy the file mexGPUExample.cu from ...

Error using mex Access denied; check that you have permissions to access.

Without Admin privilges you cannot write to the Programs folder - and this is a good idea. Copy the file mexGPUExample.cu from ...

25 días ago | 0

| accepted

Answered

For-loops are now faster than some of the simplest vectorized statements. Why do we still need so much deep copying?

I have heared the moaning in the net, that Matlab processes loops very slow. Then MathWorks has introduced the JIT acceleration ...

For-loops are now faster than some of the simplest vectorized statements. Why do we still need so much deep copying?

I have heared the moaning in the net, that Matlab processes loops very slow. Then MathWorks has introduced the JIT acceleration ...

25 días ago | 1

Answered

How to stop display of variable type in command window?

If you want the output as in old Matlab versions, you have to use old Matlab versions. To control the output, use specific func...

How to stop display of variable type in command window?

If you want the output as in old Matlab versions, you have to use old Matlab versions. To control the output, use specific func...

25 días ago | 0

Answered

Trying to create an interpolation function where Matlab asks me for value inputs.

function Y = Interpolation (X,x1,x2,y1,y2) Y = y1 + (X-x1) * (y2-y1) / (x2-x1); end Now provide the input arguments as inputs...

Trying to create an interpolation function where Matlab asks me for value inputs.

function Y = Interpolation (X,x1,x2,y1,y2) Y = y1 + (X-x1) * (y2-y1) / (x2-x1); end Now provide the input arguments as inputs...

25 días ago | 0

Answered

Matlab structure of struct

MyStruct = cell2struct(cell(2, 1), {'field1'; 'field2'}) Now the fields exist, but contain empty matrices only.

Matlab structure of struct

MyStruct = cell2struct(cell(2, 1), {'field1'; 'field2'}) Now the fields exist, but contain empty matrices only.

25 días ago | 1

| accepted

Answered

How to get the value of (V ) , using Mathlap of matrix (Write the code in step).

% V = Y \ I Y = [-12.576i, 5i, 0, 6.667i; ... 5i, -12.5i, 5i, 2.5i; ... 0, ...

How to get the value of (V ) , using Mathlap of matrix (Write the code in step).

% V = Y \ I Y = [-12.576i, 5i, 0, 6.667i; ... 5i, -12.5i, 5i, 2.5i; ... 0, ...

25 días ago | 1

Answered

How to stop particles crossing the solid cylinder boundary

What about: Outcircle = ((x_out - x_c(j)).^2 + (y_out - y_c(j)).^2) >= (D/2)^2; x_out(Outcircle) = x_previous(Outcircle); y_o...

How to stop particles crossing the solid cylinder boundary

What about: Outcircle = ((x_out - x_c(j)).^2 + (y_out - y_c(j)).^2) >= (D/2)^2; x_out(Outcircle) = x_previous(Outcircle); y_o...

25 días ago | 0

Answered

Too many open files. Close files to prevent MATLAB instability.

Yes: call fclose(fid) after the data are imported. The operating system limits the number of files, which can be open simultane...

Too many open files. Close files to prevent MATLAB instability.

Yes: call fclose(fid) after the data are imported. The operating system limits the number of files, which can be open simultane...

25 días ago | 0

| accepted

Answered

Is there a safe version of `run`?

No, this is not possible. There is always a trick to use str2func to call eval , which executes a string, which is decrypted dur...

Is there a safe version of `run`?

No, this is not possible. There is always a trick to use str2func to call eval , which executes a string, which is decrypted dur...

25 días ago | 0

Answered

How can I contact the Exchange Admin?

Use the "Contact Us" button. The categories do not really match your problem, but simple choose some almost matching details and...

How can I contact the Exchange Admin?

Use the "Contact Us" button. The categories do not really match your problem, but simple choose some almost matching details and...

25 días ago | 0

| accepted

Answered

Size of compressed image is larger than image .... How to solve this problem?

If the original image was written with a low quality, the default Quality=75 of imwrite might increase the file size.

Size of compressed image is larger than image .... How to solve this problem?

If the original image was written with a low quality, the default Quality=75 of imwrite might increase the file size.

25 días ago | 0

Answered

Any onr can help me

% Sum of i (i = 1:n): s = n * (n+1) / 2 Gauss is faster and easier. % Your solution: y = 0; for k = 0:n y = y + ((n/k)...

Any onr can help me

% Sum of i (i = 1:n): s = n * (n+1) / 2 Gauss is faster and easier. % Your solution: y = 0; for k = 0:n y = y + ((n/k)...

25 días ago | 0

Answered

Improving MATLAB programme to make it Run faster

In Matlab online one iteration needs about 3 seconds. for gamma_by_L = 0.01:0.1:5 for beta_by_L = 0.1:0.1:5 for alpha_...

Improving MATLAB programme to make it Run faster

In Matlab online one iteration needs about 3 seconds. for gamma_by_L = 0.01:0.1:5 for beta_by_L = 0.1:0.1:5 for alpha_...

25 días ago | 0

Answered

what correction is required in the code?

A hint: You want to perform this: s = 0 s = s + 2*2 s = s + 2*5 s = s + 5*8 You need to loop over the indices of m. There i...

what correction is required in the code?

A hint: You want to perform this: s = 0 s = s + 2*2 s = s + 2*5 s = s + 5*8 You need to loop over the indices of m. There i...

26 días ago | 0

Answered

How do I find f(x) if I have this definition

You have given the formula already: Create a sum from n=1:m over: (-1)^n * x^(2*n + 1) / factorial(2*n + 1) These are all term...

How do I find f(x) if I have this definition

You have given the formula already: Create a sum from n=1:m over: (-1)^n * x^(2*n + 1) / factorial(2*n + 1) These are all term...

26 días ago | 0

| accepted