Answered
How can reduce code?
I'd stay at the loop and only avoid repeated indexing: for k = 1:length(ind_cond) kk = ind_cond(k); S.Fecha ...

5 years ago | 0

| accepted

Answered
using area function - drawing below 0 of y axes
This sounds like a job for a patch: figure; axes('XLim', [0, 10], 'Ylim', [-5, 5]); patch([1,2,2,1], [-3,-3, 4,4], rand(1,3))...

5 years ago | 0

Answered
MATLAB 2020b crashing without error messages
If the code contains some C-mex functions, they can corrupt the memory. With some luck, Matlab can still work until a random fol...

5 years ago | 0

Answered
How do I subtract number from Cell?
Dice1=[1/7 1/7 1/7 1/7 1/7 2/7]; Dice2=[1/7 1/7 2/7 1/7 1/7 1/7]; ind = abs((1:length(Dice1)) - (1:length(Dice2)).') + 1; val...

5 years ago | 0

| accepted

Answered
how to set answering time window that awaits specific keypresses as response in MATLAB 2011b?
% [TESTED in R2009a] function test FigH = figure('KeyPressFcn', @KeyPressed); TimerH = timer('TimerFcn', @(TimerH, EventD...

5 years ago | 0

| accepted

Answered
Replacement for for loop in matlab
clear('sum') % Just to be sure, not for productive code Lowlim = 2; Uplim = 10; % Cleaned loop: S1 = 0; wt = -2*pi:1...

5 years ago | 0

Answered
How to write to excel file faster (writetable, writecell, writematrix or others)
Thanks for sharing this useful information. Do I understand correctly that you suggest: writetabele(data, 'UseExcel', true, 'A...

5 years ago | 0

Answered
Matlab Problem : Why after run the program, workspace or import data is disappeared ?
[After the comment has solved the problem, moved to the section for answers] Remove the clear command, which is responsible for...

5 years ago | 1

| accepted

Answered
some files and subfolders disappear while using movefile()
I tried it on a Windows PC with Matlab R2018b now: cd(tempdir); mkdir('MyTest') cd('MyTest'); for k = 'a':'z' imwrite(ra...

5 years ago | 0

Answered
check if mouse is on a button
If you post your code, the readers might see a point, which can be improved. A solution might be to create a 2D matrix with sa...

5 years ago | 0

Answered
how to plot first five numbers of data
bar(a(1:5))

5 years ago | 0

| accepted

Answered
Code to compress an Image using Huffman Coding and it should be loss less or minimum loss of data
Please use an internet search engine by your own. https://www.mathworks.com/help/comm/ref/huffmanenco.html https://www.mathwo...

5 years ago | 0

Answered
to delete some rows frm cell
Please read the Getting Started chapters of the documentation and study Matlab's Onramp to learn the basics. Do not increase th...

5 years ago | 0

Answered
Array assigning performance, : vs indexes
The performance of loops depends on the JIT acceleration. This is a smart tool, which can recognize repeated commands, reorder t...

5 years ago | 0

| accepted

Answered
Is there a function to convert column vector to matrix?
Hint: It is more efficient to omit the find() in: MOD_CER(find(MOD_CER==-9999))=NaN; % ^^^^ If you remove some arbitrar...

5 years ago | 0

| accepted

Answered
Is there any option to change the font size of figures in the entire MATLABfile?
set(groot, 'DefaultTextFontSize', 20) A smart solution is to consider this from the beginning: titleFontSize = 18; ... title...

5 years ago | 0

| accepted

Answered
How to write text file WITHOUT starting a new line
What is the contents of MCI_excel{i, j}? If the strings contain e.g. path names including "folder\next", the \n is interpreted a...

5 years ago | 1

Answered
Using different functions in a loop
for ii = 1:length(function_cell) zzz = feval(function_cell{ii}, inputs); end

5 years ago | 0

Answered
Find two x values for one y value
tmp = abs(WI - 0.707*max(WI)); minValue = min(tmp); index = (tmp == minValue); fgr = f(index) For numerical val...

5 years ago | 0

Answered
Speed up nested for loop
Maybe: % [UNTESTED CODE] Please provide inputs for testing B = 0; for m = 1:l B = B + sum(2 * real(c(m+1 : N) .* conj(v(m...

5 years ago | 0

| accepted

Answered
instead of cellfun what should we us
You can simply omit this line: IndexC = strcmpi(names,country1); % This replies a Logical vector % [row,col] = find(not(cellf...

5 years ago | 0

| accepted

Answered
Syntax for ignoring Code Analyzer warning "This statement cannot be reached"
Simply press the right mouse key on the line, which is marked in the editor. Then "supressing on this line" inserts (at least in...

5 years ago | 1

| accepted

Answered
Vectors as input and output in a function
You get the usual trouble with global variables: It is a horror to find out, which code was responsible for the last change. In ...

5 years ago | 1

| accepted

Answered
Error : Not enough input arguments
How do you call this function? Do you press the green triangle in the editor? Then no inputs are provided. You have to call this...

5 years ago | 1

| accepted

Answered
Creating a script that will allow the user to input positive n and the script calculates the cube roots of consecutive integers starting to 1until the cube root exceeds the positive integer n
The power operation has a higher precedence then the division. So n^1/3 differs from n^(1/3). Why do you stop the loop at n^1/3...

5 years ago | 0

Answered
Point not match and connect with the nearest point to line
To my surprise finding the nearest point iteratively solves the problem already: [x,y] = nearestConnection(a.Topwall(:,2), a.To...

5 years ago | 2

| accepted

Answered
fminsearch returns complex numbers as a result
If you are sure, that only the real part of the result matters, what about cropping the imaginary part? finalY = real(y(end, :)...

5 years ago | 0

Answered
Find line in skript where Figure is created
Start with defining, how the specific figure can be identified. Currently all we know is, that is is "a figure". Based on this i...

5 years ago | 0

Answered
warning: Solving was not successful. The iterative integration loop exited at time t = 0.000000 before the endpoint at tend = 0.001000 was reached
The first guess in chemical systems is usually: The problem is stiff. Then you need a solver for stiff problems as ODE15S instea...

5 years ago | 0

| accepted

Answered
How do I resolve a MATLAB installer fail with missing file
After the problem was solve by a comment, I copy the suggestion into the section for answers: Disable the virus protection soft...

5 years ago | 1

Load more