Specify colour when using script ipvd.m
1 view (last 30 days)
Show older comments
I am using the code attached (ipvd.m) to generate a progressive vector diagram for different data sets on the same figure.
How can I specify the colour of the line automatically (rather than using the plot editor manually) ?
My code calls the ipvd.m as follows:
figure
ipvd(uCurr5m/1000,vCurr5m/1000);
hold on;
ipvd(uCurr15m/1000,vCurr15m/1000);
ipvd(uCurrspred/1000,vCurrspred/1000);
ipvd(uCurrbunn/1000,vCurrbunn/1000);
I tried the following (which did not work)
p = ipvd(uCurr5m/1000,vCurr5m/1000);
set(p,'color','r');
Any help would be greatly appreciated.
Jenny
0 Comments
Answers (1)
Matt Cohen
on 16 May 2016
Hi Jenny,
I understand that you are interested in automatically specifying and modifying the color of the line in the plot generated by the function "ipvd.m".
You can accomplish this task by making a minor modification to the function's code. In the last line of code in "ipvd.m", you should return the handle to the quiver object, as follows:
q = quiver(posX(1:n),posY(1:n),vx(:),vy(:),0);
Right now, this function does not appear to return any variables, even though you are treating it like it is. You should output this quiver object from the function:
function q = ipvd(vx,vy,xo,yo)
Just like other graphics objects in MATLAB, you can modify various property values through the quiver's handle. I have included a documentation link that provides information about the quiver series properties.
For example, the following code modifies the color of the quiver's line:
q = ipvd(1:10, 1:10);
q.Color = 'green'; % One syntax for modifying color
set(q,'Color','red'); % Another syntax
I hope this helps.
Matt
0 Comments
See Also
Categories
Find more on Vector Fields in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!