Making Correlation Plots between variables.

7 visualizaciones (últimos 30 días)
Bhavick Singh
Bhavick Singh el 8 de Sept. de 2021
Respondida: Jaimin el 8 de Ag. de 2024
I have voltage, current and power in a table. However, I need only the correlation plot of voltage vs current and voltage vs power. I do not need the histogram or the least square plot. What command or technique should i use to achieve this?

Respuestas (1)

Jaimin
Jaimin el 8 de Ag. de 2024
From what I understand, you are trying to plot the correlation between voltage and current, as well as between voltage and power.
For that, you can utilize the scatterfunction, or the plot function provided by MATLAB.
Here, I have attached a sample code using the scatter function related to the issue:
% Example data
voltage = linspace(0, 10, 100); % Voltage ranging from 0 to 10 volts
current = 2 * voltage + randn(1, 100); % Current with a linear relationship to voltage plus some noise
power = voltage .* current; % Power calculated as voltage times current
% Create a figure
figure;
% Scatter plot for Voltage vs Current
subplot(1, 2, 1);
scatter(voltage, current, 'b');
title('Voltage vs Current');
xlabel('Voltage (V)');
ylabel('Current (A)');
% Scatter plot for Voltage vs Power
subplot(1, 2, 2);
scatter(voltage, power, 'r');
title('Voltage vs Power');
xlabel('Voltage (V)');
ylabel('Power (W)');
% Adjust layout
sgtitle('Correlation Plots');
For more information about the “scatter” function, refer to this documentation
For more information about “plot” function, refer to this documentation
I hope this helps you resolve your issue.

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by