# Adi is set to 0 when i = 1

1 Ansicht (letzte 30 Tage)
isamh am 3 Feb. 2020
Beantwortet: isamh am 4 Feb. 2020
i have a equation that's plus and minus 1 from values within a column. column is made up of numbers from 0 all the way to 100.
how would i convert all i = 1 to 0?
my code is:
Vd = vdi.*(Vdi==1)==0;
Adi = ((Vd + 1)-(Vd - 1)/(2*(.1));
the entire column equals to 10, must be wrong.(noticed the entire column is equal to 1 and the equation equals to 10)
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Antworten (2)

Spencer Chen am 3 Feb. 2020
Not sure what you are trying to do with Adi. If you solve the mathematical formula:
Adi = ((Vd + 1)-(Vd - 1)/(2*(.1));
So you'll get 10, no matter what.
Next, it is unclear what you mean by "convert all i = 1 to 0"? Because i is not defined.
I guess you mean convert all values in Vdi that is == 1 to 0.
You definitely did not do this correctly.
Now, you did good by finding those values in Vdi that is equal to 1:
(Vdi==1)
The problem that you had is in the assignment. You shoudl brush up on Matlab's indexing. But a hint:
Vdi(Vdi==1)
Will get you all the data in Vdi that is equal to 1.
By itself, it is not all that useful, because you know that the output of this will be all 1s. But think about what you can do with it to achieve the assignment operation that you want to do.
Blessings,
Spencer
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

isamh am 4 Feb. 2020
thanks for the response!
when Vd = Vdi_1.*(Vdi_1 == 1); it returns a row of all zeros and Adi is all 10s.
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "https://de.mathworks.com/matlabcentral/answers/503457-adi-is-set-to-0-when-i-1", "fetch_time": 1725893711000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2024-38/segments/1725700651103.13/warc/CC-MAIN-20240909134831-20240909164831-00601.warc.gz", "warc_record_offset": 181961359, "warc_record_length": 25937, "token_count": 606, "char_count": 2033, "score": 3.71875, "int_score": 4, "crawl": "CC-MAIN-2024-38", "snapshot_type": "latest", "language": "en", "language_score": 0.6801656484603882, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00048-of-00064.parquet"}