Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

How do I make a logamarithic curved line of best fit?

1 vue (au cours des 30 derniers jours)
Jake Elliott
Jake Elliott le 18 Oct 2020
Clôturé : MATLAB Answer Bot le 20 Août 2021
This is my Code:
Stim=[200 250 350 600];
Volt_Max=[max(mV200(:,3)) max(mV250(:,3)) max(mV350(:,3)) max(mV600(:,3))];
plot(Stim,Volt_Max,'h')
ylabel('Voltage (mV)')
xlabel('Stimulus Voltage (mV)')
xlim([200 700])
title('Effect of Stimulus Intensity on Active Propagations')
grid on
logx=log(Stim)
logy=log(Volt_Max)
Const=polyfit(logx, logy, 6)
hold on
plot(Stim, exp(polyval(Const, logx)));
I want a curved plot, however, the plot I get becomes this:

Réponses (1)

Durganshu
Durganshu le 19 Oct 2020
You can manually code the problem to store more intermediate values through interpolation in order to make the curve more smooth. Predefined function pchip can be used for this. Read the documentation here: https://in.mathworks.com/help/matlab/ref/pchip.html
You can also use teh Curve Fitting toolbox for your purpose. Read this documentation: https://in.mathworks.com/help/curvefit/curve-fitting.html
The easiest way to solve this issue and get a smooth curve will be to perform interpolation and obtain more values between two data points (marked with 'o' on the shown graph). This will definitely smoothen the curve.

Community Treasure Hunt

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

Start Hunting!

Translated by