Answered

How can I calculate trapz value based on an event counter and then plot it?

As far as I understand your code was almost working. I added an if condition to skip scalar data and shifted the index for the o...

How can I calculate trapz value based on an event counter and then plot it?

As far as I understand your code was almost working. I added an if condition to skip scalar data and shifted the index for the o...

19 jours ago | 1

| accepted

Answered

Polyfit polynomial badly conditioned on Linux whereas on Mac no warnings

The warning is serious. Although the results look find in your case, scaling the input is the way to go for a scientifically sta...

Polyfit polynomial badly conditioned on Linux whereas on Mac no warnings

The warning is serious. Although the results look find in your case, scaling the input is the way to go for a scientifically sta...

19 jours ago | 0

Answered

Turn code into function

Instert one line on top: function ANameOfYourchoice and save the file as "ANameOfYourchoice.m".

Turn code into function

Instert one line on top: function ANameOfYourchoice and save the file as "ANameOfYourchoice.m".

19 jours ago | 0

Answered

Running two very similar scripts, getting different resolution figures when exported.

It looks like one of the figures uses painters and the other one OpenGL as renderer. OpenGL is enabled automatically, if a more ...

Running two very similar scripts, getting different resolution figures when exported.

It looks like one of the figures uses painters and the other one OpenGL as renderer. OpenGL is enabled automatically, if a more ...

20 jours ago | 1

| accepted

Answered

How to generate a specific number of values within a range ?

R = size(Q,1); First_second_ele = zeros(R,2); Y = zeros(R, 60); for k = 1:R tmp = nonzeros(qm(k,:)); %extraction f...

How to generate a specific number of values within a range ?

R = size(Q,1); First_second_ele = zeros(R,2); Y = zeros(R, 60); for k = 1:R tmp = nonzeros(qm(k,:)); %extraction f...

21 jours ago | 0

| accepted

Answered

What is wrong with for loop iteration that is put in a function?

function bool = composite(n) bool = false; % Create a default value if n > 2 for i = 2:n for j = 2:n ...

What is wrong with for loop iteration that is put in a function?

function bool = composite(n) bool = false; % Create a default value if n > 2 for i = 2:n for j = 2:n ...

23 jours ago | 1

| accepted

Answered

How to define a function with multiple handle in a loop?

Is there a need to use an anonymous function? Why not writing a standard function? function y = pA(tau, s1, s2, s3) a=80/365...

How to define a function with multiple handle in a loop?

Is there a need to use an anonymous function? Why not writing a standard function? function y = pA(tau, s1, s2, s3) a=80/365...

23 jours ago | 0

| accepted

Answered

How can i achive this kind of plot?

Go to the FileExchange and search for "radar" or "spider" plots.

How can i achive this kind of plot?

Go to the FileExchange and search for "radar" or "spider" plots.

23 jours ago | 0

| accepted

Answered

Cell array and num2str comparison

The variable a is a cell array containing 2 scalar numbers, while b contains 2 CHAR vectors. a = {42, 12} c = {'42', '12'} Th...

Cell array and num2str comparison

The variable a is a cell array containing 2 scalar numbers, while b contains 2 CHAR vectors. a = {42, 12} c = {'42', '12'} Th...

23 jours ago | 1

| accepted

Answered

MATLAB PCode Warning on R2021a

This can happen only, if somebody has edited the file isprop.m . Modifying Matlab's built-in functions is not useful and this ca...

MATLAB PCode Warning on R2021a

This can happen only, if somebody has edited the file isprop.m . Modifying Matlab's built-in functions is not useful and this ca...

23 jours ago | 0

| accepted

Answered

Intersect() with with repetition

If you really need the redundant information in iAB_C, iAB_Cprime, idx1, idx2, this is faster than the original version tested w...

Intersect() with with repetition

If you really need the redundant information in iAB_C, iAB_Cprime, idx1, idx2, this is faster than the original version tested w...

25 jours ago | 0

| accepted

Answered

How to quickly calculate the following function？

See also: https://fredrikj.net/blog/2022/02/computing-the-lerch-transcendent/ Calculating the sum seems to be more stable. F...

How to quickly calculate the following function？

See also: https://fredrikj.net/blog/2022/02/computing-the-lerch-transcendent/ Calculating the sum seems to be more stable. F...

environ un mois ago | 0

| accepted

Answered

Artifacts when converting .svg to pdf

The output is fine, if I open your SVG in Edge and print it to a PDF using doPDF (by the way: version 7, the modern versions are...

Artifacts when converting .svg to pdf

The output is fine, if I open your SVG in Edge and print it to a PDF using doPDF (by the way: version 7, the modern versions are...

environ un mois ago | 0

Answered

I want compare the differences from each block of 10 values to the next block of 10 values until the given 100 sets of values are compared.

According to the text of the question (but not the posted code): A = rand(100, 1); B = reshape(A, 10, 10); C = diff(B...

I want compare the differences from each block of 10 values to the next block of 10 values until the given 100 sets of values are compared.

According to the text of the question (but not the posted code): A = rand(100, 1); B = reshape(A, 10, 10); C = diff(B...

environ un mois ago | 0

Answered

Mathlab program solving answr below

Maybe you want to replace for i = 1:n by for i = n:-1:1

Mathlab program solving answr below

Maybe you want to replace for i = 1:n by for i = n:-1:1

environ un mois ago | 0

Answered

Nesting depth and the error "Expected one output from a curly brace or dot indexing expression, but there were x results."

R2022a creates a different error: a(1).x.y=1; a(2).x.y=2; [a.x.y] "instead of just listing all values from across all indexe...

Nesting depth and the error "Expected one output from a curly brace or dot indexing expression, but there were x results."

R2022a creates a different error: a(1).x.y=1; a(2).x.y=2; [a.x.y] "instead of just listing all values from across all indexe...

environ 2 mois ago | 1

Answered

change user name on shared laptop?

Try to start Matlab with a batch script: SET "USERNAME=Test_Name" "C:\Program Files\MATLAB\R2022a\bin\matlab.exe" What do you...

change user name on shared laptop?

Try to start Matlab with a batch script: SET "USERNAME=Test_Name" "C:\Program Files\MATLAB\R2022a\bin\matlab.exe" What do you...

environ 2 mois ago | 1

| accepted

Answered

Intersect() with with repetition

A simple loop approach: A = [1,1; ... 1,1; ... 1,2]; B = [0,1; ... 1,1; ... 1,1]; [C, iA, iB] = Rep...

Intersect() with with repetition

A simple loop approach: A = [1,1; ... 1,1; ... 1,2]; B = [0,1; ... 1,1; ... 1,1]; [C, iA, iB] = Rep...

environ 2 mois ago | 0

Answered

Create Figures in a loop

fig = gobjects(1, 10); for i = 1:10 fig(i) = figure(); histogram(r(i,:),'Normalization','probability'); xlim([0...

Create Figures in a loop

fig = gobjects(1, 10); for i = 1:10 fig(i) = figure(); histogram(r(i,:),'Normalization','probability'); xlim([0...

environ 2 mois ago | 1

Answered

How to use cell indexes into a matrix?

Would this trivial method solve your needs? C = {B(j(1), A{1}); B(j(2), A{2}); B(j(3), A{3}); B(j(4), A{4})}

How to use cell indexes into a matrix?

Would this trivial method solve your needs? C = {B(j(1), A{1}); B(j(2), A{2}); B(j(3), A{3}); B(j(4), A{4})}

environ 2 mois ago | 0

| accepted

Answered

How do I return values from figure with out closing the figure

I assume, the calling function is stopped by uiwait? Then closing the function let Matlab resume the processing in the called. B...

How do I return values from figure with out closing the figure

I assume, the calling function is stopped by uiwait? Then closing the function let Matlab resume the processing in the called. B...

environ 2 mois ago | 0

Answered

Typecast a hex string to single

str = '7f8e2d38'; vec = uint8(sscanf(str, '%2x')); num = typecast(vec, 'single') num = typecast(flip(vec), 'single') % Mayb...

Typecast a hex string to single

str = '7f8e2d38'; vec = uint8(sscanf(str, '%2x')); num = typecast(vec, 'single') num = typecast(flip(vec), 'single') % Mayb...

environ 2 mois ago | 0

| accepted

Answered

Making a for-loop based on a condition for the third dimension of a 3D Array

Omit strange useless lines like "for i = i". AntalObjekt = 60; Procent = 0.5; A...

Making a for-loop based on a condition for the third dimension of a 3D Array

Omit strange useless lines like "for i = i". AntalObjekt = 60; Procent = 0.5; A...

environ 2 mois ago | 0

| accepted

Answered

Repeated measurements of values in a script with repeated trials

Use a loop: st = cell(1, 24); for k = 1:24 st{k} = datestr(now,'YYYY/mm/dd HH:MM:SS:FFF'); ... end

Repeated measurements of values in a script with repeated trials

Use a loop: st = cell(1, 24); for k = 1:24 st{k} = datestr(now,'YYYY/mm/dd HH:MM:SS:FFF'); ... end

environ 2 mois ago | 0

| accepted

Answered

How can I avoid pseudo random and confirm natural random ?

You can download random bits created by atmospheric noise: https://www.random.org/integers/ An alternative is to install a har...

How can I avoid pseudo random and confirm natural random ?

You can download random bits created by atmospheric noise: https://www.random.org/integers/ An alternative is to install a har...

environ 2 mois ago | 0

Answered

how to plot multiple curves in same figure

Create a loop: axes('NextPlot', 'on'); % As: hold on ... for daln = 1:5 ... end

how to plot multiple curves in same figure

Create a loop: axes('NextPlot', 'on'); % As: hold on ... for daln = 1:5 ... end

environ 2 mois ago | 0

Answered

extract all values within a if loop to be stored to be used in a figure

The code overwrite SL in each iteration. Store it as a vector instead: SL = zeros(1, Pn) for i = 1:Pn if 0<i && i <= PnC(...

extract all values within a if loop to be stored to be used in a figure

The code overwrite SL in each iteration. Store it as a vector instead: SL = zeros(1, Pn) for i = 1:Pn if 0<i && i <= PnC(...

environ 2 mois ago | 0

| accepted

Answered

How to identify two different MACI64 computers

You can create a corresponding preference on each computer: setpref('Computer', 'ID', 'Computer1'); % and on the other machine...

How to identify two different MACI64 computers

You can create a corresponding preference on each computer: setpref('Computer', 'ID', 'Computer1'); % and on the other machine...

environ 2 mois ago | 0

| accepted

Answered

Script not running for different variable size.

The empty result looks correct: The larger the time, the fewer overlapping slots you find. For Total_Time=1000 there are about u...

Script not running for different variable size.

The empty result looks correct: The larger the time, the fewer overlapping slots you find. For Total_Time=1000 there are about u...

environ 2 mois ago | 0

| accepted

Answered

Randomizing the picking and changing of values in a 3D array

x = zeros(24, 365, 60); m3 = randperm(60, 30); for i3 = m3 for i2 = 1:365 m1 = randperm(24, 4); x(m1, ...

Randomizing the picking and changing of values in a 3D array

x = zeros(24, 365, 60); m3 = randperm(60, 30); for i3 = m3 for i2 = 1:365 m1 = randperm(24, 4); x(m1, ...

environ 2 mois ago | 1

| accepted