Plotting With Arrays on Surf Function

calculating the array correctly, yet when recalling it for displying on surf plot its just a flat surface

 Accepted Answer

How did you paste that code in there? I can't copy it. You didn't paste an image did you? We can't run an image. Post your code as code, or else attach it with the paperclip icon.
What is "laptime"? It doesn't change inside the loop so it's not surprising your array is all the same value.
Anyway, plot is a function. Do not use it as a variable name.

5 Comments

%Sensitivity Analysis
Axisl = [0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1 1.01 1.02 1.03 1.04 1.05 1.06 1.07 1.08 1.09 1.1];
plot = zeros;
for k = 1:21
m = 650 * Axisl (k);
%D_Weight = 0.46 * Axis1 (k);
%R_Weight = 1-D_Weight;
%CDA = 0.35 * Axis1 (k);
%CLA2 = 0.50 * Axis1 (k)
%CoG = 275 * Axis1 (k);
%mu_long = 1.45 * Axis1 (k);
%mu_lat = 1.38 * Axis1 (k);
%D_Aero2 = 0.45 * Axis2 (k);
%R_Aero = 1-D_Aero2;
%FinalDR = 10/37 * Axis1 (k);
for j = 1:21
%m = 650 * Axis1 (j);
%D_Weight = 0.46 * Axis1 (j);
%R_Weight = 1-D_Weight;
%CDA = 0.35 * Axis1 (j);
%CLA2 = 0.50 * Axis2 (j);
%CoG = 275 * Axis1 (j);
mu_long = 1.45 * Axisl (j);
mu_lat = 1.38 * Axisl (j);
%D_Aero2 = 0.45 * Axis1 (j);
%R_Aero = 1-D_Aero2;
%GearRatio = 21/29 * Axis1 (j);
%Sensitivity Analysis End
plot (k,j) = Laptime;
end
end
Unrecognized function or variable 'Laptime'.
surf(plot)
xlabel('Mass = -10% -> +10%')
ylabel('Weight Distribution 10% -> 10%')
zlabel('LapTime (s)')
Again, what is Laptime and how is it supposed to change upon every iteration?
laptime = 38.1615 btw
just realised it wont work need to change original code to then refernce laptime as an array into this new section, appriciate the repsonses though
@fraser watts, if you have Laptime defined in advance somehow you can perhaps do
myPlot(k,j) = Laptime(k, j);

Sign in to comment.

More Answers (1)

Every iteration you are storing the exact same value Laptime, which never changes.

Products

Release

R2022a

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!