Réponse apportée
I need two outputs and I'm only getting one, please help me
You didn't actually assign any outputs, so Matlab only stores the first one in ans. If you want to actually store variables you ...

plus de 5 ans il y a | 0

Réponse apportée
What is the probability that their children can travel in a straight line between any two points without leaving the boundary? In other words, what is the probability that the boundary is a convex quadrilateral? 
If you want to do a Monte-Carlo-style simulation, I would suggest using rand to generate the coordinates. I would suggest puttin...

plus de 5 ans il y a | 0

Réponse apportée
Annually averaging of a 4D matrix
You are using the color operator incorrectly. 1:2:3 doesn't mean [1 2 3], but [1 3]. If your syntax does indeed work for you, t...

plus de 5 ans il y a | 0

| A accepté

Réponse apportée
finding a phrase in a modularized code with over 1000 functions
You can use Matlab tools, as Ameer describes, but you can also use external software. I personally find the performance of searc...

plus de 5 ans il y a | 0

Réponse apportée
How to plot data with >2 dimensions?
Apart from plot3 (as Alan suggested), you may also consider using subplot to divide the different scenarios and using hold to pl...

plus de 5 ans il y a | 0

Question


minify Matlab code (minimize number of characters)
I would like to find a way that reduces the footprint of a function as much as possible. The actual functionality should not cha...

plus de 5 ans il y a | 2 réponses | 2

2

réponses

Réponse apportée
How can I get my figure window to pop up with the animation playing when I execute the code?
You probably mean you want to make the figure the current figure and bring it to the foreground. If so: figure(1) cla;%i...

plus de 5 ans il y a | 0

| A accepté

Réponse apportée
Find the element that is a sqrt of another element in the same array function?
To compare many elements to each other I would recommend the ismember function.

plus de 5 ans il y a | 0

Réponse apportée
Refresh annotate on figure in loop
Create the annotation object once, and update the String property inside your loop. I would suggest drawnow to trigger the upda...

plus de 5 ans il y a | 0

Réponse apportée
Locate elements of a vector inside a meshgrid
I would suggest using ismembertol, or consider functions like normxcorr2 from the image processing toolbox.

plus de 5 ans il y a | 0

Réponse apportée
How do I read this file and extract the data to plot and average it
Good call on not using str2num, you should consider using str2double (or textscan or datetime) instead: [date,value]=read_json_...

plus de 5 ans il y a | 0

Réponse apportée
clean all paths except factory ones (toolboxes)
Appart from using restoredefaultpath, you might consider borrowing code from toggleToolbox to toggle the states of your path.

plus de 5 ans il y a | 0

Réponse apportée
How do I create an exact looping code for my following problem?
You are remove all elements from phi, so your second iteration does what you ask: nothing. Please learn how to use the debuggin...

plus de 5 ans il y a | 0

Réponse apportée
Crop a part of binary image
My suggestion would be to determine the number of white pixels in each column, and use an automatic way to determine a threshold...

plus de 5 ans il y a | 0

| A accepté

Réponse apportée
I'm having problem while running a code with nested for loops. I'm not able to generate the output graph
I'm not going to read your code when it is like this, but the most common source of the issue is that people are not indexing th...

plus de 5 ans il y a | 0

Réponse apportée
What is it called when I specify a vector output of solutions from, say, fsolve?
Those are called output arguments. Sometimes functions will use the nargout function to determine which calculations should be p...

plus de 5 ans il y a | 1

| A accepté

Réponse apportée
Output argument "xn" (and maybe others) not assigned during call to "myGeneralRecursion".
You're close with the components of your function, but you're not quite there. Your function is trying to find a value for xn. I...

plus de 5 ans il y a | 0

Réponse apportée
Importing a two column array from excel
You forgot to put the quotes in your first call. That makes Matlab treat it like a variable, not a char array.

plus de 5 ans il y a | 1

Réponse apportée
how to make a looping function to delete all members in a phi set?
You don't update the original variable, but you create a new one instead. You also have made a typo when writing the code here, ...

plus de 5 ans il y a | 0

Réponse apportée
Fast subsetting or indexing of data
Whenever you find yourself copy-pasting code in Matlab, you should consider an array. seasons={'Spring','Summer','Autumn','Wint...

plus de 5 ans il y a | 0

| A accepté

Réponse apportée
What frustrates you about MATLAB? #2
Comment posted by John in the previous thread: Matlab should 'update' the new version instead of installing the new version. Th...

plus de 5 ans il y a | 1

Réponse apportée
How to read data from a file into cell array keeping indents undisturbed
You can get my readfile function from the FEX or through the AddOn-manager (R2017a or later). It will read a file to a cell arr...

plus de 5 ans il y a | 3

Réponse apportée
How to asign Unicode string to popup menu without fonr error?
Since you're using a release pre-R2020a, the default to store m-files is not UTF-8. That means any special character has a very ...

plus de 5 ans il y a | 0

| A accepté

Réponse apportée
SOS: How do I get the same amount of positive and negative values in a random vector?
Your question differs from your description. If you want to select the points with both x and y above 0, you need to use both as...

plus de 5 ans il y a | 1

Réponse apportée
bug in power calcultion while in loop ?
This is not a bug. Look at the exponent: 2e-16 is very small. It is close enough to eps that you can assume that is just 0. The...

plus de 5 ans il y a | 1

| A accepté

Réponse apportée
Reshape panel data to wide using text scan
If you want to read an Excel file you can use the aptly named xlsread function. The second or third output is probably what you ...

plus de 5 ans il y a | 0

Réponse apportée
Redistribution of histogram type data in specified bins
You should be really careful with this resampling, especially for so few samples. Since you're assuming a flat distribution in ...

plus de 5 ans il y a | 0

Réponse apportée
Need help with perimeter of polygon
Step by step. Split up your problems in manageable parts. If you have the coordinates of all corners of your polygon, you can u...

plus de 5 ans il y a | 0

Réponse apportée
matlab calculation area circular
You can use trapz for a numerical approximation of an integration. By selecting your bounds you can use this to calculate the ar...

plus de 5 ans il y a | 2

| A accepté

Réponse apportée
Code is not working, can someone help me?
This should fix it: function s = Sum1(x,y,z) s = 0; for i=0:min(x,y) for k=0:x-i s = s + (-1)^k * QuantumDi...

plus de 5 ans il y a | 1

Charger plus