필터 지우기
필터 지우기

how to convert python code to matlab

조회 수: 2 (최근 30일)
Yasyfa Rifiani Putri
Yasyfa Rifiani Putri 2021년 11월 6일
댓글: Yasyfa Rifiani Putri 2021년 11월 6일
Hi, all! I've a problem when converting the python code to MATLAB. Below is my python code, can you help?
import random
import statistics
shadow = []
for i in range(20):
x = random.randint(1, 20)
shadow.append(x)
shadow_mean = statistics.mean(shadow)
shadow_st_dev = statistics.stdev(shadow)
shadow_value = np.random.normal(loc=shadow_mean, scale=shadow_st_dev, size=20)

답변 (1개)

Chunru
Chunru 2021년 11월 6일
% import random
% import statistics
% shadow = []
% for i in range(20):
% x = random.randint(1, 20)
% shadow.append(x)
shadow = randi([1 20], [20 1]);
% first [1 20] is range of rand num;
% second [20 1] is the size of shadow
shadow_mean = mean(shadow)
shadow_mean = 10.3500
shadow_st_dev = std(shadow)
shadow_st_dev = 4.6143

카테고리

Help CenterFile Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by