Answered
Why does Matlab say my function is undefined?
If you strip out most of the commands, the main structure of your code looks like this: n=input('Enter an integer for two, th...

5 years ago | 0

Answered
netcdf reading parameters "Error using double Out of memory. Type HELP MEMORY for your options"
What does the ncdisp command tell you about the variable sizes? Just paste the output of the following: ncdisp('dataset-oc-med...

5 years ago | 2

| accepted

Answered
Why does this data file cause Matlab to lock-up?
This is just a guess, but... Did you have a script named TrajData.m open in the editor at the time you first made the typo? Mat...

6 years ago | 1

Answered
attach a field to a shapefile and plot it
Do you need to actually add a new field to the shapefiles themselves? Or just add it to the read-in structure in Matlab? If ...

6 years ago | 2

| accepted

Answered
How can I write an unformated string to file, i.e., without interpreting % and any other special characters
You can pass the string as a parameter to a simple '%s' formatter, rather than using the string itself as a format: >> fpri...

6 years ago | 2

| accepted

Answered
How to use datenum with a date represented as a scaler?
Is your final goal to convert to a datenumber or an year-month-day array? As mentioned in the other answers, if you're using a ...

6 years ago | 2

| accepted

Answered
Recreating a figure from its handle after it has been closed
No, the figure handle itself does not contain that information. The graphics objects handles loose their link to the relevant d...

6 years ago | 0

Answered
Graph Plotting! Which Function Shall I use?
A beeswarm plot might be an option... the <https://www.mathworks.com/matlabcentral/fileexchange/37105-plot-spread-points-beeswar...

6 years ago | 1

Answered
How do I read, change and write data back into the same txt file, at the same place?
To replace a specific bit of text in a text file, you're going to have to rewrite the entire file. Assuming the files above are...

6 years ago | 6

| accepted

Answered
Plotting hitmap with different box size
You can create this pretty easily using patches: The test data: c = rand(20,9)*2 - 1; % Color value s = c; ...

6 years ago | 1

| accepted

Answered
How can i crop a figure
Just to clarify, when you say "like a map", you don't mean it's a map axis (Mapping Toolbox), do you? Cropping a map axis is mu...

6 years ago | 0

Answered
How can I display elements of a 2D matrix as blue, green and red squares?
You just need to set the color limits: set(gca, 'clim', [0 10]);

6 years ago | 0

| accepted

Answered
How to Draw a Line Between Two Points on Different Axes
I suggest using annotations paired with the very handy <https://www.mathworks.com/matlabcentral/fileexchange/13634-axescoord2fig...

6 years ago | 1

Answered
Calculate number of hours below a threshold temperature
I think you should be able to accomplish this by retiming twice; once to fill in any gaps with whatever method you prefer, and t...

6 years ago | 2

| accepted

Answered
My circular_prime function only works well for two_digit input
I'd suggest looking at the |circshift| function.

6 years ago | 1

| accepted

Answered
How can I polar plot in decibels?
If you have a recent version of Matlab (R2016a or later), you can use polaraxes/polarplot to get much more flexibility in settin...

6 years ago | 1

| accepted

Answered
How to get the order indices in a character array?
c = {... 'x_air' 'v_air' 'p_headspace' 'p_environment' ...

6 years ago | 4

| accepted

Answered
What is this stack trace and what can I do to avoid it?
This isn't really an answer to the why of the question, but I can agree that this is a common problem (in my experience, at leas...

6 years ago | 0

Answered
How to plot temporal changes in batches of data?
Assuming your file is read into a table array, I think the quickest way to do this is to unstack the SSID data and then plot: ...

6 years ago | 1

Answered
Is the upper limit of a color bar the true maximum value of the data in the color map, or is it larger ?
The color limits are usually set to match the plotted data for most standard functions (pcolor, surf, imagesc, etc), although th...

6 years ago | 0

| accepted

Answered
Is there a function to identify whether polylines are located inside a polygonal region?
You can try out my <https://github.com/kakearney/lineinpolygon-pkg lineinpolygon.m> function. (Sorry, the GitHub repo doesn't h...

6 years ago | 1

| accepted

Answered
seimlogx not working in an iteration
The |hold on| command is the culprit... you're issuing it before you plot, so the linear axis is being held throughout. If you ...

6 years ago | 1

| accepted

Answered
How to avoid white patch in contourf ?
Matlab's |contourf| function doesn't actually plot contour faces for lower-than-lowest-clevel regions when are unenclosed. (And...

6 years ago | 2

Answered
How can I quickly find the intersections between many individual line segments and a polygon?
Is your polygon always convex? If so, you can do the ray extension from each polygon vertex in all directions at once, and assu...

6 years ago | 1

| accepted

Answered
Insert specific number of rows of zeroes(5) after every 56 rows in my n*m matrix. I am able to create matrices but can I do the insertion without loop given I know the size of matrix? Thanks for help
Another approach, which works even if your data doesn't divide evenly: x = rand(21,6); nrow = 5; % number of ro...

6 years ago | 0

| accepted

Answered
gscatter: connecting groups by lines through this function
The |gscatter| function already plots the data as line objects... you just need to add a visible line style: h = gscatter(....

6 years ago | 3

Answered
Legend not showing markers
I've found that legends can sometimes benefit from taking a deep breath. Not sure exactly why, but it seems that since the intr...

6 years ago | 7

Answered
Why is an empty string not empty? isempty('') returns true, but isempty("") returns false
I think string arrays function more like cell arrays in this context... the first element of the string itself isn't empty, but ...

6 years ago | 4

Answered
Given the location (coordinates) of a point in a gridmesh, how can I extract the number of the grid that the point is located in?
You can use the |discretize| function to bin points: nx = 2; ny = 2; xedge = linspace(0,1,nx+1); yedge = lin...

6 years ago | 4

| accepted

Answered
Stretch parts of axis (non uniform axis)
You could scale the data appropriately and then overwrite the tick labels, but assuming you only have a few scaling blocks, I of...

6 years ago | 2

Load more