please help me solve this and also tell me what i did wrong m=2x^3-2y-​sqrt(x-y^3​)/(1+(x-y)​/(x^2+3))+​sin(x/y*pi​)+exp^(y/3​)

1 view (last 30 days)
m = 2*x.^3-2*y-sqrt(x-y.^3)./(1+(x-y)./(x.^2+3))+sin(x./y*pi)+exp(y/3)

Answers (1)

Image Analyst
Image Analyst on 15 Sep 2021
Easy enough to type out, but so what. What do you want to do with m? Show it as an image or a surface or something? What range do you want for x and y?
% Demo by Image Analyst
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format short g;
format compact;
fontSize = 20;
numPoints = 500;
xlin = linspace(-5, 5, numPoints);
ylin = linspace(-8, 8, numPoints);
[x, y] = meshgrid(xlin, ylin);
m = 2*x.^3-2*y-sqrt(x-y.^3)./(1+(x-y)./(x.^2+3))+sin(x./y*pi)+exp(y/3);
m = real(m);
% show as an image.
subplot(2, 1, 1);
imshow(m, []);
axis('on', 'image');
xlabel('x', 'FontSize', fontSize);
ylabel('y', 'FontSize', fontSize);
colorbar;
% Show as a surface
subplot(2, 1, 2);
surf(x, y, m, 'EdgeColor', 'none');
xlabel('x', 'FontSize', fontSize);
ylabel('y', 'FontSize', fontSize);
zlabel('m', 'FontSize', fontSize);

Community Treasure Hunt

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

Start Hunting!