Dynamically updating density graphs with values from slider in MATLAB

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I have two complex data matrices $A,B$. I can combine them using functions $f(A,B,x,y),g(A,B,x,y)$. For simplicity, say my functions are $f(A,B,x,y)=xA+yB$ and $g(A,B,x,y)=xA-yB$. I would like to graph the functions $|f(A,B,x,y)|$, $argleft(f(A,B,x,y)vphantom^2right)$, $|g(A,B,x,y)|$ and $argleft(g(A,B,x,y)vphantom^2right)$ in MATLAB and have them dynamically update as I change the values of $x$ and $y$ using sliders. Is this possible? A couple of hours of googling and playing around with my code taught me a few things about sliders but not how to combine them with graphs.



So far, I've managed to place the four graphs in a single figure, but I have no idea how to include the sliders in the figure, have them update the values of $x$ and $y$ and have the graphs respond accordingly. Here's my code:



figure;
h=;
h(1)=subplot(3,2,1);
h(2)=subplot(3,2,2);
h(3)=subplot(3,2,3);
h(4)=subplot(3,2,4);
h(5)=subplot(3,2,5);
h(6)=subplot(3,2,6);
image(abs(xA+yB),'CDataMapping','scaled','Parent',h(1)),colormap(autumn),set(gcf,'name','linear combination...','numbertitle','off'),xlabel(''),ylabel('');
image(angle(xA+yB),'CDataMapping','scaled','Parent',h(2)),colormap(autumn),set(gcf,'name','linear combination...','numbertitle','off'),xlabel(''),ylabel('');
image(abs(xA-yB),'CDataMapping','scaled','Parent',h(3)),colormap(autumn),set(gcf,'name','linear combination...','numbertitle','off'),xlabel(''),ylabel('');
image(angle(xA-yB),'CDataMapping','scaled','Parent',h(4)),colormap(autumn),set(gcf,'name','linear combination...','numbertitle','off'),xlabel(''),ylabel('');


I've included a third row of subplots to place the sliders in, but if that isn't the correct way to do it I can simply remove h(5) and h(6) and change all the subplot(3,2,...)s to subplot(2,2,...)s.



Thanks!







share|cite|improve this question















  • 1




    I think stackoverflow is a more appropriate site to post this question.
    – callculus
    Aug 2 at 17:52






  • 1




    Thanks. I've posted it there.
    – Rain
    Aug 2 at 19:07










  • You´re welcome and good luck.
    – callculus
    Aug 2 at 19:10














up vote
1
down vote

favorite












I have two complex data matrices $A,B$. I can combine them using functions $f(A,B,x,y),g(A,B,x,y)$. For simplicity, say my functions are $f(A,B,x,y)=xA+yB$ and $g(A,B,x,y)=xA-yB$. I would like to graph the functions $|f(A,B,x,y)|$, $argleft(f(A,B,x,y)vphantom^2right)$, $|g(A,B,x,y)|$ and $argleft(g(A,B,x,y)vphantom^2right)$ in MATLAB and have them dynamically update as I change the values of $x$ and $y$ using sliders. Is this possible? A couple of hours of googling and playing around with my code taught me a few things about sliders but not how to combine them with graphs.



So far, I've managed to place the four graphs in a single figure, but I have no idea how to include the sliders in the figure, have them update the values of $x$ and $y$ and have the graphs respond accordingly. Here's my code:



figure;
h=;
h(1)=subplot(3,2,1);
h(2)=subplot(3,2,2);
h(3)=subplot(3,2,3);
h(4)=subplot(3,2,4);
h(5)=subplot(3,2,5);
h(6)=subplot(3,2,6);
image(abs(xA+yB),'CDataMapping','scaled','Parent',h(1)),colormap(autumn),set(gcf,'name','linear combination...','numbertitle','off'),xlabel(''),ylabel('');
image(angle(xA+yB),'CDataMapping','scaled','Parent',h(2)),colormap(autumn),set(gcf,'name','linear combination...','numbertitle','off'),xlabel(''),ylabel('');
image(abs(xA-yB),'CDataMapping','scaled','Parent',h(3)),colormap(autumn),set(gcf,'name','linear combination...','numbertitle','off'),xlabel(''),ylabel('');
image(angle(xA-yB),'CDataMapping','scaled','Parent',h(4)),colormap(autumn),set(gcf,'name','linear combination...','numbertitle','off'),xlabel(''),ylabel('');


I've included a third row of subplots to place the sliders in, but if that isn't the correct way to do it I can simply remove h(5) and h(6) and change all the subplot(3,2,...)s to subplot(2,2,...)s.



Thanks!







share|cite|improve this question















  • 1




    I think stackoverflow is a more appropriate site to post this question.
    – callculus
    Aug 2 at 17:52






  • 1




    Thanks. I've posted it there.
    – Rain
    Aug 2 at 19:07










  • You´re welcome and good luck.
    – callculus
    Aug 2 at 19:10












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have two complex data matrices $A,B$. I can combine them using functions $f(A,B,x,y),g(A,B,x,y)$. For simplicity, say my functions are $f(A,B,x,y)=xA+yB$ and $g(A,B,x,y)=xA-yB$. I would like to graph the functions $|f(A,B,x,y)|$, $argleft(f(A,B,x,y)vphantom^2right)$, $|g(A,B,x,y)|$ and $argleft(g(A,B,x,y)vphantom^2right)$ in MATLAB and have them dynamically update as I change the values of $x$ and $y$ using sliders. Is this possible? A couple of hours of googling and playing around with my code taught me a few things about sliders but not how to combine them with graphs.



So far, I've managed to place the four graphs in a single figure, but I have no idea how to include the sliders in the figure, have them update the values of $x$ and $y$ and have the graphs respond accordingly. Here's my code:



figure;
h=;
h(1)=subplot(3,2,1);
h(2)=subplot(3,2,2);
h(3)=subplot(3,2,3);
h(4)=subplot(3,2,4);
h(5)=subplot(3,2,5);
h(6)=subplot(3,2,6);
image(abs(xA+yB),'CDataMapping','scaled','Parent',h(1)),colormap(autumn),set(gcf,'name','linear combination...','numbertitle','off'),xlabel(''),ylabel('');
image(angle(xA+yB),'CDataMapping','scaled','Parent',h(2)),colormap(autumn),set(gcf,'name','linear combination...','numbertitle','off'),xlabel(''),ylabel('');
image(abs(xA-yB),'CDataMapping','scaled','Parent',h(3)),colormap(autumn),set(gcf,'name','linear combination...','numbertitle','off'),xlabel(''),ylabel('');
image(angle(xA-yB),'CDataMapping','scaled','Parent',h(4)),colormap(autumn),set(gcf,'name','linear combination...','numbertitle','off'),xlabel(''),ylabel('');


I've included a third row of subplots to place the sliders in, but if that isn't the correct way to do it I can simply remove h(5) and h(6) and change all the subplot(3,2,...)s to subplot(2,2,...)s.



Thanks!







share|cite|improve this question











I have two complex data matrices $A,B$. I can combine them using functions $f(A,B,x,y),g(A,B,x,y)$. For simplicity, say my functions are $f(A,B,x,y)=xA+yB$ and $g(A,B,x,y)=xA-yB$. I would like to graph the functions $|f(A,B,x,y)|$, $argleft(f(A,B,x,y)vphantom^2right)$, $|g(A,B,x,y)|$ and $argleft(g(A,B,x,y)vphantom^2right)$ in MATLAB and have them dynamically update as I change the values of $x$ and $y$ using sliders. Is this possible? A couple of hours of googling and playing around with my code taught me a few things about sliders but not how to combine them with graphs.



So far, I've managed to place the four graphs in a single figure, but I have no idea how to include the sliders in the figure, have them update the values of $x$ and $y$ and have the graphs respond accordingly. Here's my code:



figure;
h=;
h(1)=subplot(3,2,1);
h(2)=subplot(3,2,2);
h(3)=subplot(3,2,3);
h(4)=subplot(3,2,4);
h(5)=subplot(3,2,5);
h(6)=subplot(3,2,6);
image(abs(xA+yB),'CDataMapping','scaled','Parent',h(1)),colormap(autumn),set(gcf,'name','linear combination...','numbertitle','off'),xlabel(''),ylabel('');
image(angle(xA+yB),'CDataMapping','scaled','Parent',h(2)),colormap(autumn),set(gcf,'name','linear combination...','numbertitle','off'),xlabel(''),ylabel('');
image(abs(xA-yB),'CDataMapping','scaled','Parent',h(3)),colormap(autumn),set(gcf,'name','linear combination...','numbertitle','off'),xlabel(''),ylabel('');
image(angle(xA-yB),'CDataMapping','scaled','Parent',h(4)),colormap(autumn),set(gcf,'name','linear combination...','numbertitle','off'),xlabel(''),ylabel('');


I've included a third row of subplots to place the sliders in, but if that isn't the correct way to do it I can simply remove h(5) and h(6) and change all the subplot(3,2,...)s to subplot(2,2,...)s.



Thanks!









share|cite|improve this question










share|cite|improve this question




share|cite|improve this question









asked Aug 2 at 17:32









Rain

317




317







  • 1




    I think stackoverflow is a more appropriate site to post this question.
    – callculus
    Aug 2 at 17:52






  • 1




    Thanks. I've posted it there.
    – Rain
    Aug 2 at 19:07










  • You´re welcome and good luck.
    – callculus
    Aug 2 at 19:10












  • 1




    I think stackoverflow is a more appropriate site to post this question.
    – callculus
    Aug 2 at 17:52






  • 1




    Thanks. I've posted it there.
    – Rain
    Aug 2 at 19:07










  • You´re welcome and good luck.
    – callculus
    Aug 2 at 19:10







1




1




I think stackoverflow is a more appropriate site to post this question.
– callculus
Aug 2 at 17:52




I think stackoverflow is a more appropriate site to post this question.
– callculus
Aug 2 at 17:52




1




1




Thanks. I've posted it there.
– Rain
Aug 2 at 19:07




Thanks. I've posted it there.
– Rain
Aug 2 at 19:07












You´re welcome and good luck.
– callculus
Aug 2 at 19:10




You´re welcome and good luck.
– callculus
Aug 2 at 19:10















active

oldest

votes











Your Answer




StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
);
);
, "mathjax-editing");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "69"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2870313%2fdynamically-updating-density-graphs-with-values-from-slider-in-matlab%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2870313%2fdynamically-updating-density-graphs-with-values-from-slider-in-matlab%23new-answer', 'question_page');

);

Post as a guest













































































Comments

Popular posts from this blog

What is the equation of a 3D cone with generalised tilt?

Color the edges and diagonals of a regular polygon

Relationship between determinant of matrix and determinant of adjoint?