• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Matlab axes

Herr Kutz

Platinum Member
I'm trying to scale axes in Matlab to a certain size without having to manually change the axes every time I run my simulation. I would like to set the x axes only and leave the y axes as default.

I am using -inf and inf for the yaxis limits because I would like those to stay at default values. However, it changes the y axis limits to the maximum and minimum value of the waveform instead of leaving a little bit of space at the top and bottom when I don't set limits.

Here is a picture that explains what I want a little better:
(the first image shows simulation with no axis settings--but I had to manually change x axis because it keeps showing time longer than my simulation--, the second shows the simulation with axis settings)
matlabhelp.gif


I am using this code:
axis([0 1.2 -inf inf])


Oh yeah, I can't just replace -inf with 0 because I am going to be plotting sinusoidal waveforms too.
 
Can't you find min/max value for y-axis from your data and use it to set y axis, say by adding a fixed value or a percentage? Also, assigning axis to a variable will return xy limits, perhaps you could retrieve them and set a new axis based on those. Unfortunately I don't have Matlab any more, so I can't try it myself...

Instead of -inf you can use 5.. and use 45 instead of inf.
And with another simulation he might need e.g. 10 and 65, and yet another -5 and 30, so he'll have to manually change it every time - exactly what he said he didn't want to do 😉
 
Back
Top