Issue getting gscatter to separate by group - matlab

I want to create an understeer plot from telemetry I have for a corner of a racing circuit. I am trying to plot 'GPS Speed' against 'Steering Angle' where group is the 'Run' (i.e WarmUp, ConstantSpeed, Endurance1 or Endurance2).
MATLAB code
The data I have is for several laps of the whole circuit so I have split it into the relevant data points for each lap. When I run the script, it does produce a scatter graph with all the data but it only displays the group of the last plot and applies the same colour to all:
Is there a way I can fix this? I wondered whether if I could import the specified columns from the csv file into a matrix first as I would then only require one gscatter plot to display everything I require.

Related

Three data sets in one plot in Tableau

The goal is to plot three data sets in one plot:
(DATE1_GOOD, DATE1_BAD);
(DATE2_GOOD, DATE2_BAD);
(DATE3_GOOD, DATE3_BAD).
Unfortunately, I'm getting all possible combinations:
So now the task is to combine the three diagonal plots into one and delete the rest since they make no sense. I tried dragging the axes but the result is not what I'm looking for, I get:
(DATE3_GOOD, DATE1_BAD);
(DATE3_GOOD, DATE2_BAD);
(DATE3_GOOD, DATE3_BAD):
I'm new to Tableau, is it even possible to do what I want?

How to compare graphically the raw data to the fitted distribution

I have a data series and estimated the parameters of the probability density function I wanted. It's a pdf that isn't in the MATLAB "distribution fitting" app and another that is but I modified to be exactly what I wanted.
The problem is when I'm doing the goodness of fit starting to compare the adjusted pdf with the empircal distribution.
I don't know if the y-axis is supposed to be in frequency but I'm doing it all in density.
What I've got:
The red line I'm supposed to have but flipped:
The thing is, in the first graph the normal is nicely enquadrated but the other two distribution are not. First, none was enquadrated but then I normalized the histogram:
histogram(DATAs,'Normalization','pdf')
But as you can see in the second graph the red one is supposed to be along with the histogram while on the first one is completely separated. (It's the same data, the only thing is that in the second one I estimated using the "distribution fitting" app with positive values and I plan to do a flip when passing to the first one).
I'm starting to think that the problem is when plotting the pdf. Do I need to adjust the pdf scale in order to have the second image in the first one?
Supposing that the parameters are correctly estimated. The pdf plot I did like this:
x_DATAs =linspace(minval1,maxval1,10000);
parmhat=[parmhat DATAs(1),parmhatDATAs(2),parmhatDATAs(3)];
y2_ DATAs = sgtpdf(x_DATAs ,parmhat,parmhat DATAs(4),parmhatDATAs(5));
plot(x_ DATAs ,y2_ DATAs , '--g')
I wanted to get something like this:

How to plot multiple functions in same figure (subplot) in Simulink?

Similar to what we can do with the subplot command in MATLAB to have many plots in a single figure, How can I plot different graphs in same figure using Simulink?
Note:
I am not asking about multiplotting which I already know how to do that using vector concatenate + scope but it gives me overriding plots. I am unable to find a way that I could have a separate subplot for each function.
Any help?
Have multiple inputs for your scope (image shows right-click menu)
Show multiple plots from the layout menu (up to 16x16 plots) of the open scope
VoilĂ , subplots! As per the documentation, the first n traces will be shown in the first n subplots of the layout. Any traces which can't be shown individually will all be grouped within the last subplot.

How to combine different figures in a Matlab script?

I am workin on a some sort of System test wherein i have a set of readings in the form of a .mat file.
It has a structure in the .mat file with one field as Measurement. It has several Arrays(e.g air mass flow, velocity, carbon content) which further have fields like time and value.
From these, I Need to plot the velocity and the air mass flow against time. For that i wrote the following command which gave me the corresponding plots:
plot(Measurement.(Measurement.air_mass_flow.time),Measurement.air_mass_flow.value)
plot(Measurement.(Measurement.velocity.time),Measurement.velocity.value)
Now i Need to create a script in matlab wherein i can get both the curves one under the other i.e. on the same page. Can anyone help in the Approach i should procede with ?
ok now i will further extend my question.
I have two fields as velocity and acceleration. I Need to plot it on the same curve with grids on for the comparison. But the y axis for both are different.
the velocity y-axis is: (0:20:120), which should be displayed on the left side and the acceleration y-axis is: (0:2:12) which should be displayed on the right side.
i wrote the following code for this:
plot(Measurement.(Measurement.VehV_v.time),Measurement.VehV_v.value)
grid on
set(gca,'xtick',[0:500:2000])
set(gca,'ytick',[0:20:120])
hold on
plot(Measurement.(Measurement.accel_w.time),Measurement.accel_w.value)
grid on
set(gca,'xtick',[0:500:2000])
set(gca,'ytick',[0:2:12])
Do i Need to write a function for that as i am directly reading the values from the structure.
plotyy() also doesnt seem to work
But the axis are not matching and the graph for acceleration is very small. Could anyone help me out with this ?
I also want to add a Picture of the Graphs here but unfortunately there is some error here. I hope the question is clear without the Picture.
Yes you can use the subplot command, e.g.:
figure
subplot(1,2,1)
plot(Measurement(Measurement.air_mass_flow.time),Measurement.air_mass_flow.value)
subplot(1,2,2)
plot(Measurement.(Measurement.velocity.time),Measurement.velocity.value)
You can use help subplot on Matlab for further details or have a look at this:
https://www.dartmouth.edu/~rc/classes/matlab_graphics/Matlab-subplots.html

MATLAB: Plotting two different axes on one figure

The MATLAB surf plot below is essentially two plots plotted adjacent to each other. For clarity, I have included some code below used to prepare the plot:
band1 = horzcat(band1, eSurface2(:,:,1));
band2 = horzcat(band2, eSurface2(:,:,2));
surf(band2,'DisplayName','band2');
surf(band3,'DisplayName','band2');
I would like for the y axis numbering to restart at the start of the second graph. How do I go about doing that?
You can use the 'YTick' and 'YTickLabel' properties of the axis to control the ticks, this way you can make it start from zero for the second graph. It will require some trail and error to get it right. See the relevant doc here (you'll have to scroll all the way to the bottom of the page).
Take advantage of the following feature of 'YTickLabel': "If you do not specify enough text labels for all the tick marks, MATLAB uses all of the labels specified, then reuses the specified labels".