필터 지우기
필터 지우기

Quiver plot with a Third feature using background colour

조회 수: 1 (최근 30일)
SHUBHAM PATEL
SHUBHAM PATEL 2022년 4월 24일
답변: Aditya 2023년 11월 23일
Could someone tell how can we add a third feature which is represented by the background color in the quiver plot?
As explained in a previous question and answer thread, how can we add an another property which is expectation value of sigma_z.
In the code above if we want to add another two line.
% before the 'for' loop
sigma_z = [1,0;0,-1]; %sigma_z
%After the for loop
expz = pagemtimes(pagemtimes(Psi,'ctranspose',sigma_z,'none'),Psi); % BL's change here
expz = reshape(expz,[M M]); % BL's change here
And if we want to reflect the magnitude of espectation value of z by background color of the quiver plot, is it possible in MATLAB?
PS: The magnitude of expz is very small (zero), still I want to know the way.

답변 (1개)

Aditya
Aditya 2023년 11월 23일
Hi Shubham,
I understand that you want to add a third feature which is represented by background color in the quiver plot. You can achieve this by using the imagesc function. Here's how you can modify your code to include it:
% Create the quiver plot with background color
figure;
imagesc(kx, ky, abs(expz)); % Plot the background color based on |expz|
colormap('jet'); % Set the colormap
colorbar; % Show the colorbar
hold on;
quiver(KX, KY, expx, expy); % Overlay the quiver plot
hold off;
In the code above, abs(expz) determines the color intensity of each point in the background, with the colormap set to jet for a range of colors. The colorbar provides a reference for the magnitude of expz”.
For more information on the imagesc function and its properties, you can refer the below MATLAB documentation:
Hope this helps!

카테고리

Help CenterFile Exchange에서 Vector Fields에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by