"for" cycle to plot the point in a matrix with a certain radius
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
javarocket
il 24 Mar 2023
Commentato: javarocket
il 24 Mar 2023
Hi everyone,
I have a compressor blade defined in polar-cylindrical coordinates and I would like to write a script that plot just the points located at a certain radius (that will correspond to the hub or to the shroud of the blade).
I tried to use the code below, but it did not work.
Does anyone could help me?
Thank you very much
clear all
close all
clc
data = importdata("blade_pol.mat")
radius = data(:,1)
x = data(:,3);
y = data(:,1).*data(:,2);
for k = 1:size(data,1)
if radius(k,1) == 0.1160
plot(x(k),y(k))
end
end
0 Commenti
Risposta accettata
Dyuman Joshi
il 24 Mar 2023
You should use tolerance to compare floating point numbers. Set tolerance according to the level of precision you want.
And use hold on command to retain all the points on the same plot, otherwise your plot will be over-written.
for k = 1:size(data,1)
if abs(radius(k,1) - 0.1160)<1e-4 %tolerance
plot(x(k),y(k))
hold on
end
end
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Annotations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!