5 788 total contributions since 2014

Suspensa Vix Via Fit

Answered

how to call different functions of a matlab file to another matlab file

Local functions are only visible to other functions within the same M-file: https://www.mathworks.com/help/matlab/matlab_prog/l...

how to call different functions of a matlab file to another matlab file

Local functions are only visible to other functions within the same M-file: https://www.mathworks.com/help/matlab/matlab_prog/l...

1 jour ago | 0

Answered

saving for loop results not working

"Can anyone please explain to me what im doing wrong and how to fix it." Your first code does not store/allocate/sum the output...

saving for loop results not working

"Can anyone please explain to me what im doing wrong and how to fix it." Your first code does not store/allocate/sum the output...

1 jour ago | 0

Answered

lsqcurvefit Error using /

Replacing both of the mrdivide operators with rdivide operators gets rid of the error: >> fun = @(x,xd) (x(1)*(1+(sqrt(1+xd./x(...

lsqcurvefit Error using /

Replacing both of the mrdivide operators with rdivide operators gets rid of the error: >> fun = @(x,xd) (x(1)*(1+(sqrt(1+xd./x(...

1 jour ago | 0

| accepted

Answered

Find mean of rows containing decimal numbers in between integers in a column

>> Y = [1,0.098,0.00076,0.01,2,0.099,0.007,2,0.003,0.04,0.1,4]; >> X = cumsum([1;diff(~mod(Y(:),1))]~=0); >> Z = accumarray(X(...

Find mean of rows containing decimal numbers in between integers in a column

>> Y = [1,0.098,0.00076,0.01,2,0.099,0.007,2,0.003,0.04,0.1,4]; >> X = cumsum([1;diff(~mod(Y(:),1))]~=0); >> Z = accumarray(X(...

1 jour ago | 4

Answered

How to set constraints of griddata results are all non-negative?

"Is there any way to control the range of interpolation results?" You could simply adjust the output data yourself: A = max(0,...

How to set constraints of griddata results are all non-negative?

"Is there any way to control the range of interpolation results?" You could simply adjust the output data yourself: A = max(0,...

1 jour ago | 0

| accepted

Answered

fopen does not work when put text code

You are adding extra single quotes, here: lgttext = (".lgt'"); % ^ superfluous Roriginaltitle = insertBefore(sp...

fopen does not work when put text code

You are adding extra single quotes, here: lgttext = (".lgt'"); % ^ superfluous Roriginaltitle = insertBefore(sp...

2 jours ago | 3

Answered

How do I change a function name within a loop using variables?

You can store function handles in a cell array and use indexing: >> C = {@(x)2*x+3,@(x)sqrt(x)+1}; % {1st fun,2nd fun} >> C{1}...

How do I change a function name within a loop using variables?

You can store function handles in a cell array and use indexing: >> C = {@(x)2*x+3,@(x)sqrt(x)+1}; % {1st fun,2nd fun} >> C{1}...

2 jours ago | 2

| accepted

Answered

How to split an array by same length and make a matrix?

>> a = 1:72; >> b = reshape(a,24,[]).' b = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ...

How to split an array by same length and make a matrix?

>> a = 1:72; >> b = reshape(a,24,[]).' b = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ...

2 jours ago | 1

| accepted

Answered

Having trouble changing mouse cursor to "watch" to indicate that function is busy.

This worked for me: set(gcf, 'Pointer','watch') drawnow() % <- you need this ... set(gcf, 'pointer','arrow') Note that the ...

Having trouble changing mouse cursor to "watch" to indicate that function is busy.

This worked for me: set(gcf, 'Pointer','watch') drawnow() % <- you need this ... set(gcf, 'pointer','arrow') Note that the ...

3 jours ago | 0

Answered

Interpolating linearly between many values in a vector

>> t_old = 1:10; % times 1:N >> rate = 1000; % 1 kHz >> t_new = linspace(t_old(1),t_old(end),(numel(t_old)-1)*rate+1);

Interpolating linearly between many values in a vector

>> t_old = 1:10; % times 1:N >> rate = 1000; % 1 kHz >> t_new = linspace(t_old(1),t_old(end),(numel(t_old)-1)*rate+1);

3 jours ago | 0

Answered

How to check if one of output variables is not called

You can use nargout to detect how many output arguments are requested: if nargout>0 varargout{1} = x+y; end if nargout>1...

How to check if one of output variables is not called

You can use nargout to detect how many output arguments are requested: if nargout>0 varargout{1} = x+y; end if nargout>1...

3 jours ago | 0

Answered

I have multiple equations that depend on a specific value and would like matlab to ask the user which equation to use and what the specific value is and then print that value but it's giving me trouble.

Your code is mixed up with the (meta-)data (i.e. the variable names named as material types), which is a very bad practice and s...

I have multiple equations that depend on a specific value and would like matlab to ask the user which equation to use and what the specific value is and then print that value but it's giving me trouble.

Your code is mixed up with the (meta-)data (i.e. the variable names named as material types), which is a very bad practice and s...

3 jours ago | 0

Answered

cprintf not work in linux command window

"open a command window in Linux system" cprintf works in the MATLAB Command Window: https://www.mathworks.com/help/matlab/ref/...

cprintf not work in linux command window

"open a command window in Linux system" cprintf works in the MATLAB Command Window: https://www.mathworks.com/help/matlab/ref/...

3 jours ago | 0

| accepted

Answered

Interrupting a Callback with a Push Button

" Is there another trick you recommend for this issue" The simplest solution is to use nested functions: simply define a logica...

Interrupting a Callback with a Push Button

" Is there another trick you recommend for this issue" The simplest solution is to use nested functions: simply define a logica...

3 jours ago | 0

Answered

Conversion to cell from double is not possible

A = cell2mat(dataC(:,1)); B = A * pi * 2; dataC(:,3) = num2cell(B); % <- you need NUM2CELL!

Conversion to cell from double is not possible

A = cell2mat(dataC(:,1)); B = A * pi * 2; dataC(:,3) = num2cell(B); % <- you need NUM2CELL!

3 jours ago | 1

| accepted

Answered

remove row of matrix inside cell

You could use cellfun like this: >> F = @(m,x) m(setdiff(1:size(m,1),x),:); >> C = cellfun(F,A,B,'uni',0); >> C{:} ans = ...

remove row of matrix inside cell

You could use cellfun like this: >> F = @(m,x) m(setdiff(1:size(m,1),x),:); >> C = cellfun(F,A,B,'uni',0); >> C{:} ans = ...

3 jours ago | 0

| accepted

Answered

Writing table variables with quotations marks ("Placeholder variable name")

'QuoteStrings',true https://www.mathworks.com/help/matlab/ref/writetable.html#btyc9ne-1_sep_btyc9ne-1-QuoteStrings Otherwise i...

Writing table variables with quotations marks ("Placeholder variable name")

'QuoteStrings',true https://www.mathworks.com/help/matlab/ref/writetable.html#btyc9ne-1_sep_btyc9ne-1-QuoteStrings Otherwise i...

4 jours ago | 1

Answered

Taking out entries of a Vector to make a new Vector

Where V is your vector: X = V(4:4:end); Y = V; Y(4:4:end) = [];

Taking out entries of a Vector to make a new Vector

Where V is your vector: X = V(4:4:end); Y = V; Y(4:4:end) = [];

8 jours ago | 0

| accepted

Answered

automatically filling a matrix

Method one: eye and kron: >> n = 5; >> j = 6; >> M = kron(-eye(j),ones(n,1)) M = -1 0 0 0 0 0 ...

automatically filling a matrix

Method one: eye and kron: >> n = 5; >> j = 6; >> M = kron(-eye(j),ones(n,1)) M = -1 0 0 0 0 0 ...

10 jours ago | 0

| accepted

Answered

Looping within a structure

You can easily loop over the fieldnames: F = fieldnames(mystruct); for k = 1:numel(F) A = mystruct.(F{k}); ... do wh...

Looping within a structure

You can easily loop over the fieldnames: F = fieldnames(mystruct); for k = 1:numel(F) A = mystruct.(F{k}); ... do wh...

10 jours ago | 0

| accepted

Answered

How to convert a structure array into vector

S(1).F1 = [1,2,3,4,5]; S(2).F1 = [10,20]; S(1).F2 = [2,4,6,8,10]; S(2).F2 = [150,200]; F = fieldnames(S); C = num2cell(stru...

How to convert a structure array into vector

S(1).F1 = [1,2,3,4,5]; S(2).F1 = [10,20]; S(1).F2 = [2,4,6,8,10]; S(2).F2 = [150,200]; F = fieldnames(S); C = num2cell(stru...

10 jours ago | 1

| accepted

Answered

Storing multiple matrices created by multiple executions of a function

Method one: input/output arguments: function [A,B] = mainfun(N) [A,B] = recfun(N,{},{}); end function [A,B] = recfun(N,A,B) ...

Storing multiple matrices created by multiple executions of a function

Method one: input/output arguments: function [A,B] = mainfun(N) [A,B] = recfun(N,{},{}); end function [A,B] = recfun(N,A,B) ...

10 jours ago | 0

| accepted

Answered

How can I find consecutive digits seperated by spaces?

Simple solution using a dynamic match expression: >> str = '1 1 1 4 4 6 7 7 7 7'; >> out = regexprep(str,'(\d)(??( $1)*)','${n...

How can I find consecutive digits seperated by spaces?

Simple solution using a dynamic match expression: >> str = '1 1 1 4 4 6 7 7 7 7'; >> out = regexprep(str,'(\d)(??( $1)*)','${n...

10 jours ago | 1

| accepted

Answered

Output from nested struct into numerical / string array

string({mystruct.somenesting.objecttype.name}) cat(1,mystruct.somenesting.somethingelse.size) % ^ change this to suit the si...

Output from nested struct into numerical / string array

string({mystruct.somenesting.objecttype.name}) cat(1,mystruct.somenesting.somethingelse.size) % ^ change this to suit the si...

10 jours ago | 0

| accepted

Answered

convert a 10x2 matrix into x,y coordinates

>> M = [1,2;3,4;5,6] M = 1 2 3 4 5 6 >> V = 1:size(M,1); >> fprintf('(x%d,y%d)=(%d,%d)\n',[V;V;M.']) (x1,y1)=(1,...

convert a 10x2 matrix into x,y coordinates

>> M = [1,2;3,4;5,6] M = 1 2 3 4 5 6 >> V = 1:size(M,1); >> fprintf('(x%d,y%d)=(%d,%d)\n',[V;V;M.']) (x1,y1)=(1,...

12 jours ago | 0

| accepted

Answered

tic, toc, apear to be reporting incorrect times when called in App Designer button callback

Try specifying the output variable: t = tic(); ... toc(t) Or record the time yourself: tstart = now(); ... now()-tstart ...

tic, toc, apear to be reporting incorrect times when called in App Designer button callback

Try specifying the output variable: t = tic(); ... toc(t) Or record the time yourself: tstart = now(); ... now()-tstart ...

18 jours ago | 1

| accepted

Answered

Convert single string with many numbers to vector

Very simple, very efficient, no evil eval: >> hue = '10 20 30 40 50'; >> vec = sscanf(hue,'%f',[1,Inf]) vec = 10 20 3...

Convert single string with many numbers to vector

Very simple, very efficient, no evil eval: >> hue = '10 20 30 40 50'; >> vec = sscanf(hue,'%f',[1,Inf]) vec = 10 20 3...

18 jours ago | 0

Answered

Row interpolation by adding data at end of the matrix

>> V = interp1(1:18,d,1:20,'pchip','extrap'); >> V(:) ans = 24.1615256950601 24.1615256699363 24.1615256438020 ...

Row interpolation by adding data at end of the matrix

>> V = interp1(1:18,d,1:20,'pchip','extrap'); >> V(:) ans = 24.1615256950601 24.1615256699363 24.1615256438020 ...

19 jours ago | 0

| accepted

Answered

assign header line value to variable

A very simple and very efficient method without eval and without shadowing the inbuilt size: >> str = 'size=256 256 256;'; >> ...

assign header line value to variable

A very simple and very efficient method without eval and without shadowing the inbuilt size: >> str = 'size=256 256 256;'; >> ...

19 jours ago | 0

Answered

question about vectorization using indexes

Note that ind and b must be transposed for this to work: >> a = [4;2;1;3;1;4;4;0]; % must be column! >> ind = [1,0;2,3;4,0;3...

question about vectorization using indexes

Note that ind and b must be transposed for this to work: >> a = [4;2;1;3;1;4;4;0]; % must be column! >> ind = [1,0;2,3;4,0;3...

20 jours ago | 0

| accepted