۱ مطلب با کلمه‌ی کلیدی «#example» ثبت شده است

مثال numpy

(1)کد برنامه:

% Matrix Multiplication using NumPy in MATLAB
clc;clear;
% Import the NumPy module in Matlab
py.importlib.import_module('numpy');
A=py.numpy.array({{1,2,3},{4,5,6}});
B=py.numpy.array({{7,8},{9,10},{11,12}});
C=py.numpy.dot(A,B);
C=double(py.array.array('d',py.numpy.nditer(C)));% Convert the resulting NumPy array to a MATLAB array
% 'd' specifies that the elements should be of type double
disp(C)

.

(2)کد برنامه:

%Calculating Mean and Standard Deviation using NumPy in MATLAB

clc;clear;
% Import the NumPy module in Matlab
py.importlib.import_module('numpy');
% Define a 1D array 'data' using NumPy array
data = py.numpy.array({1,2,3,4,5});
% Calculate the mean of the data using NumPy's mean function
% Convert the resulting NumPy array to a MATLAB array of type double
mean_value = double(py.numpy.mean(data));
% Calculate the standard deviation of the data using NumPy's std function
% Convert the resulting NumPy array to a MATLAB array of type double
std_dev = double(py.numpy.std(data));
% Display the mean and standard deviation
disp(['mean: ',num2str(mean_value), ' , Standard Deviation: ',num2str(std_dev)]);

۰ ۰ ۰ دیدگاه


تبلیغات
Blog.ir بلاگ، رسانه متخصصین و اهل قلم، استفاده آسان از امکانات وبلاگ نویسی حرفه‌ای، در محیطی نوین، امن و پایدار
bayanbox.ir صندوق بیان - تجربه‌ای متفاوت در نشر و نگهداری فایل‌ها، ۳ گیگا بایت فضای پیشرفته رایگان
Bayan.ir - بیان، پیشرو در فناوری‌های فضای مجازی ایران