Making Correlation Plots between variables.

10 次查看(过去 30 天)
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?

回答(1 个)

Jaimin
Jaimin 2024-8-8,10:57
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.

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by