Hi When I run my code I got an error message "Invalid expression. Check for missing or extra characters" for my if loop. I am not sure why. Someone there can help me?

% Define the velocity components
u
= @(x, y, t) 0;
v
= @(x, y, t) 2*y + 2*y*cos(t);
% 1) Plot streamlines at two instants of time
figure
;
[x, y] = meshgrid(-5:0.5:5, -5:0.5:5);
% First instant of time (t1)
t1
= 0;
streamline(x, y, u(x, y, t1), v(x, y, t1), 0, 0);
hold on
;
% Second instant of time (t2)
t2
= 2;
streamline(x, y, u(x, y, t2), v(x, y, t2), 0, 0);
title('Streamlines at Two Instants of Time');
xlabel('X-axis');
ylabel('Y-axis');
grid on
;
axis equal
;
when i running this why it is not showing stream lines in gaph only plan graph is coming after run

Answers (1)

u1 = @(x, y, t) 0
u1 = function_handle with value:
@(x,y,t)0
u2 ...
= @(x, y, t) 0
u2 = function_handle with value:
@(x,y,t)0
% u3
% = @(x, y, t) 0
Don't split the code among multiple lines (as u1), or if you do use an ellipsis to continue the expression onto the next line (as u2).
I'm a bit confused why your question says you have a loop, since your code doesn't contain any of the looping keywords.

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Asked:

on 29 Nov 2023

Answered:

on 29 Nov 2023

Community Treasure Hunt

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

Start Hunting!