help with fixing my plot please

Any insight on how to make my graph not jagged and more rounded or smooth so doesnt look so bad and also how to change the colors since i have 12 different forces i need 12 different colors so there arent two the same.. New to graphing so trying to figure this out and going crazy. Attatched is an image of my code and the matrix i am trying to graph (A_total) as well as an image of my current graph. Any insight would greatly be appreciated.

 Risposta accettata

My version of MATLAB cannot run images of code, only actual code, so I created an equivalent-size ‘A’ matrix:
A = rand(5, 12); % Create Data
figure
plot(A)
grid
title('Original')
xi = linspace(1, 5, 24); % Define ‘x’ With Increased Resolution
Ai = interp1((1:5).', A, xi, 'pchip'); % Interpolate
cm = jet(size(A,2)); % Define Colormap For Line Colors
figure
hold on
for k = 1:size(Ai,2)
plot(xi, Ai(:,k), 'Color',cm(k,:))
end
grid
title('Interpolated & Unique Colours')
This interpolates the matrix rows and then defines a colormap to plot lines with different colours. (Theare are alternate ways to do it without using the loop, however the loop is likely easiest.) Experiment with it to get the result you want.

6 Commenti

Thank you very much
As always, my pleasure!
Star Strider, your information greatly helped however I have one last small question. My x values in my graph are supposed to be from -90 degrees to +90 degrees. when i change your code from a 1,5,24 to -pi/2, pi,2,24 it worked however it changes my y values and makes them incorrect. Any insight would be great. Attatched is an image of my current graph and code based upon your reponse yesterday as well as my actual code.
I am completely lost (the reason I did not post an Answer to your other Question on this exact topic).
The interpolation will only work to interpolate values within the range of the existing values. It might be necessary to calculate your matrix using the angle values.
Here, it might be easier to simply re-label the x-axis ticks:
A = rand(5, 12); % Create Data
figure
plot(A)
grid
title('Original')
xi = linspace(1, 5, 24); % Define ‘x’ With Increased Resolution
Ai = interp1((1:5).', A, xi, 'pchip'); % Interpolate
cm = jet(size(A,2)); % Define Colormap For Line Colors
figure
hold on
for k = 1:size(Ai,2)
plot(xi, Ai(:,k), 'Color',cm(k,:))
end
xt = get(gca,'XTick');
set(gca, 'XTick',xt, 'XTickLabel',compose('%.2f',linspace(-pi/2,pi/2,numel(xt))))
grid
title('Interpolated & Unique Colours')
Beyond that, I have absolutely no idea because I have no idea what you are doing.
this solution fixed the problem thank you.
As always, my pleasure!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Creating, Deleting, and Querying Graphics Objects in Centro assistenza e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by