Dec-29-2022, 01:53 PM
How can I convert Python code to MATLAB code?
Convert Python code to MATLAB code
|
Dec-29-2022, 01:53 PM
How can I convert Python code to MATLAB code?
Dec-29-2022, 06:26 PM
By working hard I guess. I don't think there is an automated translator.
(Dec-29-2022, 06:26 PM)Gribouillis Wrote: I don't think there is an automated translator.Should maybe not mention but AI🎠is starting to get better in many ways. import numpy as np arr2 = np.array([[1, 2, 3], [4, 5, 6]]) for idx, x in np.ndenumerate(arr2): print(idx, x) snippsat Wrote:can you translate to mathlab? ChatGPT Wrote:Sure! Here is how you could translate the code you provided to MATLAB: arr2 = [1, 2, 3; 4, 5, 6]; % Create 2D array for idx = 1:numel(arr2) % Iterate over elements of the array [i, j] = ind2sub(size(arr2), idx); % Convert linear index to subscript index x = arr2(i, j); % Get element value fprintf('(%d, %d) %d\n', i, j, x); % Print indices and element value endDon't even complain about effort as we many times do ![]()
Dec-29-2022, 08:28 PM
Dec-30-2022, 02:06 AM
Gribouillis Wrote:This is quite impressive. I wonder how it works. And also what it can do and what it cannot do.I think you might reach these guys by using this little thing |
|