Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Getting an error after rounding data.

1 visualizzazione (ultimi 30 giorni)
Afzal
Afzal il 21 Apr 2013
Chiuso: MATLAB Answer Bot il 20 Ago 2021
I get an error saying 'Index exceeds matrix dimensions.' when I try to plot data rounded to 3 decimal places. It works fine without rounding.
filtered_hand = sprintf('%6.3f',filtered_hand)
plot3(handles.axes4, filtered_hand(index(j),1), filtered_hand(index(j),2), filtered_hand(index(j),3), 'o')
  1 Commento
Afzal
Afzal il 21 Apr 2013
Modificato: Afzal il 21 Apr 2013
I figured it out. I need to use num2str(data, precision) instead of sprintf. I actually wanted to do the following:
plot3(handles.axes4, filtered_hand(index(j),1), filtered_hand(index(j),2), filtered_hand(index(j),3), 'o')
set(handles.text1, 'String', ['The position of target ' num2str(j) ' is x = ' num2str(filtered_hand(index(j),1),3) ' m y = ' num2str(filtered_hand(index(j),2),3) ' m z = ' num2str(filtered_hand(index(j),3),3) ' m '])

Risposte (1)

Azzi Abdelmalek
Azzi Abdelmalek il 21 Apr 2013
Modificato: Azzi Abdelmalek il 21 Apr 2013
After
filtered_hand = sprintf('%6.3f',filtered_hand)
filtered_hand becomes a string
If you want to round to 3 decimals use
filtered_hand = round(filtered_hand*1000)/1000

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by